## Search found 16 matches

Wed Nov 10, 2004 9:23 am
Forum: Volume 4 (400-499)
Topic: 495 - Fibonacci Freeze
Replies: 222
Views: 33558
try to change

[java]
static int main()
[/java]

to

[java]
public static void main( String [] args )
[/java]

and

[java]
else if( n < 0 ) return 0;
[/java]

to

[java]
else if( n < 0 ) return ;
[/java]

this will at least let your code to run on OJ ( i believe ) ; )

hope this helps
Thu Nov 04, 2004 7:35 am
Forum: Volume 1 (100-199)
Topic: 103 - Stacking Boxes
Replies: 200
Views: 22759
Tue Nov 02, 2004 12:32 am
Forum: Volume 1 (100-199)
Topic: 103 - Stacking Boxes
Replies: 200
Views: 22759
[cpp] for (int i=0;i<=K-1;i++) for (int j=0;j<=N-2;j++) for (int k=j+1;k<=N-1;k++) if (A [j]>A [k]) { tempI=A [j]; A [j]=A [k]; A [k]=tempI; } [/cpp] this is slow.. around O(n^2) bubble * n times = O(n^3), you might want to consider using a faster sorting alrgorithm (qsort in C, or sort in C++ STL) ...
Fri Oct 29, 2004 8:43 pm
Forum: Volume 3 (300-399)
Topic: 350 - Pseudo-Random Numbers
Replies: 56
Views: 17160
1. [cpp] numProduced.push_back(randomNum); int first= randomNum; int count=1; while(1) { randomNum=(Z*randomNum+I)%M; if(Search(numProduced,randomNum)) break; numProduced.push_back(randomNum); count++; } [/cpp] this will give you a WA iff the number doesn't start at the first place.. ex. the sequenc...
Thu Oct 28, 2004 2:02 am
Forum: Volume 3 (300-399)
Topic: 350 - Pseudo-Random Numbers
Replies: 56
Views: 17160
What do you mean "maybe you want to at least push the generated random number into the vector?" ? I already pushed the generated numbers into the vector! Yeah, I tried while(!(Z==0&&I==0&&M==0&&L==0)) but there's no difference. I still get the wrong answer. Huhm! you pushed the first generated rand...
Wed Oct 27, 2004 9:56 am
Forum: Volume 3 (300-399)
Topic: 350 - Pseudo-Random Numbers
Replies: 56
Views: 17160
maybe you want to at least push the generated random number into the vector?

and try to change
[cpp]
while(Z!=0&&I!=0&&M!=0&&L!=0)
[/cpp]

to
[cpp]
while(!(Z==0&&I==0&&M==0&&L==0))
[/cpp]

hope this helps
Tue Oct 26, 2004 11:12 am
Forum: Volume 6 (600-699)
Topic: 620 - Cellular Structure
Replies: 18
Views: 5347
ah.. good to hear =)
Tue Oct 26, 2004 10:55 am
Forum: Volume 6 (600-699)
Topic: 620 - Cellular Structure
Replies: 18
Views: 5347
1. if the length is even, it is a MUTANT. 2. if the length is 1 and it is not 'A', it is a MUTANT. 3. if the length is 1 and it is 'A', it is a SIMPLE. 4. go through the string of cells from the end, also keep track of your position from the start of the string. loop until you found a MUTANT (those ...
Tue Oct 26, 2004 8:29 am
Forum: Volume 5 (500-599)
Topic: 576 - Haiku Review
Replies: 50
Views: 18008
I think the strcmpi in your code is causing the problem. Note that strcmpi is valid neither in ANSI C nor in UNIX. To avoid CE (though I myself have recieved 80 CEs to date :wink:), remember that judge uses UNIX system to compile your program. instead of strcmpi, use strcmp (make sure you #include ...
Tue Oct 26, 2004 12:02 am
Forum: Volume 100 (10000-10099)
Topic: 10018 - Reverse and Add
Replies: 169
Views: 22551
195
4 9339
265
5 45254
750
3 6666
2
0 2
99
0 99
6
0 6
4000000000
1 4000000004
20
1 22
100
1 101
Mon Oct 25, 2004 11:59 pm
Forum: Volume 100 (10000-10099)
Topic: 10062 - Tell me the frequencies!
Replies: 235
Views: 39860
try this:
BBCCDD
C
AAABBBCCC

expected output:
68 2
67 2
66 2

67 1

67 3
66 3
65 3

68 2
67 2
66 2

67 1

65 3

hope this helps
Mon Oct 25, 2004 11:05 pm
Forum: Volume 3 (300-399)
Topic: 350 - Pseudo-Random Numbers
Replies: 56
Views: 17160
But be careful: the cycle might not begin with the seed! since the seed might not be in the cycle, you want to take note of every random number that the algorithm produce (You can use an array to keep track of everything, and check if you already found that number everytime you generate a new rando...
Mon Oct 25, 2004 10:33 pm
Forum: Volume 4 (400-499)
Topic: 448 - OOPS!
Replies: 18
Views: 4707
Your code does not terminate when it reaches the End Of File, so

[cpp]
int
{
do
{
if(scanf("%c",&Cmd)==EOF) return 0;
}while (Cmd=='\n');
return 1;
}
[/cpp]
Mon Oct 25, 2004 10:03 pm
Forum: Volume 4 (400-499)
Topic: 495 - Fibonacci Freeze
Replies: 222
Views: 33558
[c]
for (;; ) {
if (!scanf ("%d", &n)) break;
/* change the line above to if(scanf("%d",&n)==EOF) break; */
printf ("The Fibonacci number for %d is ", n);
[/c]

hope this helps
Mon Oct 25, 2004 9:52 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 195909
your code does not produce the right answer for the sample data. 1. You forget to reset the value of maxc after each run. 2. You skip some numbers (and it happens that one of the number produces the maximum cycle length), eg. 1 10 (your output is 9) 3. for TLE, you might want to consider using memoi...