Search found 39 matches

Sat Mar 05, 2005 3:48 pm
Forum: C++
Topic: vector->at(i) ?
Replies: 4
Views: 2689
You can do it like this: "(*p)[1]". For example,

Code: Select all

``````vector<int>* p;
p=new vector<int>();
p->push_back(4);
p->push_back(8);
printf("%d\n", (*p)[1]);
delete p;``````
Wed May 12, 2004 6:06 pm
Forum: Algorithms
Topic: Optimisation
Replies: 5
Views: 1641
Hello. Hmmm, I'm not entirely sure about this. Looking up a table involves pointer arithmetics, so I don't think you gain anything by exchanging an integer subtraction with a pointer addition... You know, I thought about this too, but I remember that it gave me a little boost on one of the problems....
Tue May 11, 2004 9:59 pm
Forum: Algorithms
Topic: Optimisation
Replies: 5
Views: 1641
I did this pervert code writing for a while... :) In "string-int" there is a faster way (performing less arithmetic operations using a look-up table). In "int-string" you can speed this up considerably. Let me give you a hint: get rid of two divisions (very expensive operation) and reverse(buffer). ...
Wed May 05, 2004 10:22 pm
Forum: Volume 106 (10600-10699)
Topic: 10650 - Determinate Prime
Replies: 67
Views: 23920
mavy wrote:I found 156 sequences from 1 to 32000, is this correct ?
No.
sohel wrote:And I got 162 different determinate sequence for 0 32000. Is this correct?
Yes.
Mon Apr 19, 2004 7:56 pm
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 7979
WR, hi.
Sorry for leaving you waiting for so long.

Your code looks good to me. I still suggest reading in a char-by-char way. I think you should try it if it helped Bernardo. (Bernardo, did it?)

PS: Hey, you don't dispose anything!..
Sun Apr 18, 2004 8:48 pm
Forum: Volume 106 (10600-10699)
Topic: 10634 - Say NO to Memorization
Replies: 18
Views: 8277
By the way, make sure you don't use the advantage of the fact that

Code: Select all

``c(n, k) = c(n, k-1) * (n-k+1) / k``
There will be trouble with the overflow.
Sat Apr 03, 2004 11:54 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 172940
Justin, hi.
Justin wrote:If the program is wanting more than 4 inputs or there is some strict strict procedure that you aren't telling people who're new to this system, i'd like to know.
You should read until end-of-file. That's all. Good luck!
Sat Mar 27, 2004 10:49 pm
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 7979
Bernardo, hi. 1) I suggested reading in a char-by-char way, because there might be some spaces or blank lines in the end after the last number and Pascal might not detect the end of input properly. 2) The whole input file is one big sequence of numbers. You should not stop when end-of-line is reache...
Sat Mar 27, 2004 7:23 pm
Forum: Volume 4 (400-499)
Topic: 484 - The Department of Redundancy Department
Replies: 103
Views: 7979
I have this one solved in Pascal a long time ago. Longint is OK and the array size is around 100,000. The only thing I can suggest: try reading in a char by char way. Or rewrite it in C/C++.
Sat Mar 27, 2004 3:25 pm
Forum: Algorithms
Topic: help with one "usaco hard problem" ... please.....
Replies: 19
Views: 9437
Hello.
The post is 3 months old... are you still stuck with it? I believe I could give you some hints on this one.
Thu Mar 25, 2004 12:34 am
Forum: Other words
Topic: Problems from past World Finals
Replies: 3
Views: 3005
Take a look here: http://acmicpc-live-archive.uva.es.

Happy solving!
Mon Mar 22, 2004 3:01 pm
Forum: Volume 4 (400-499)
Topic: 437 - The Tower of Babylon
Replies: 14
Views: 7808
Joan, hi. This is my output: Case 1: maximum height = 342 Case 2: maximum height = 588 Case 3: maximum height = 5 Case 4: maximum height = 481 Case 5: maximum height = 180 Case 6: maximum height = 273 Case 7: maximum height = 200 Case 8: maximum height = 310 Case 9: maximum height = 50 Hope that hel...
Mon Mar 22, 2004 12:54 am
Forum: Volume 7 (700-799)
Topic: 750 - 8 Queens Chess Problem
Replies: 78
Views: 25706
There's a blue tick next to the problem's name on this page. It means multiple input. I'll copy-paste the meanings of the colours: The yellow colour means a special correction program for that problem; the blue colour means multiple input; finally, the green colour (a mix of blue and yellow) means a...
Sun Mar 21, 2004 11:54 pm
Forum: Volume 7 (700-799)
Topic: 750 - 8 Queens Chess Problem
Replies: 78
Views: 25706
Well, it's a multiple input problem... Probably, 20 is the number of test cases.

PS: For the description of multiple input format take a look here.

Good luck!
Sat Mar 06, 2004 9:25 pm
Forum: Volume 8 (800-899)
Topic: 825 - Walking on the Safe Side
Replies: 38
Views: 19952
Dima, hi. I think I have an answer to your not a very recent question. :) Is it nessesary to use long arithmetic? Nope. Can somebody post a few inputs and outputs? Here you are: 8 1 1 1 1 8 1 1 8 1 4 8 1 1 2 3 4 5 6 7 8 8 1 1 2 3 4 1 5 6 7 8 4 4 1 2 3 4 8 8 1 2 3 5 4 1 4 5 3 6 6 2 7 7 8 8 8 8 1 2 6 ...