Search found 10 matches

by nightdog
Mon Jul 19, 2004 6:43 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

by looking quikly at your code i believe your problem is that you forgot to add an if-clause to handle switched input (cases that a > b).

cheers,
Ricardo Cabral
by nightdog
Sun Feb 15, 2004 5:40 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

JW: i mean the way you do your output is wrong...

WRONG:

1 10
1 10 X
2 20
2 20 Y

Right
1 10
2 20
[eof]
1 10 X
2 20 Y
by nightdog
Sun Feb 15, 2004 5:39 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

you're probably right, because C++ has a cleaner way to process input/output...
by nightdog
Sat Feb 14, 2004 5:09 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

if you got a time limit exceeded from the online judge, it's probably because your algorithm is slow or inefficient in some point.. i'd suggest changing the part where you find the higher cycle length, here's a suggestion: instead of using an array to store all values of the cycle length, override t...
by nightdog
Fri Feb 06, 2004 12:41 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

your program does not output correctly... it should wait for the end of all the input, and then output the results by order... besides that, your program seems fine :)

good luck
by nightdog
Thu Jan 29, 2004 6:01 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

in the second one, you don't quit the program unless you have a valid INPUT with the value 0. the judge doesn't input u that value, it just gives you an EOF. the solution would be checking for EOF in the return value of scanf, not it's variables. wrong: [c] scanf("%d %d",&i,&j); wh...
by nightdog
Tue Jan 27, 2004 1:26 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

congratz dude!

good luck with the next problem :)
by nightdog
Fri Jan 23, 2004 4:56 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

Access denied

If you got an answer from the online judge saying you're not permitted to use that host to submit, it means you have the option to only accept submissions by e-mail. you can either submit your code using the e-mail you specified when you subscribed or change that parameter, which can be done by goin...
by nightdog
Thu Jan 22, 2004 5:54 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

output problem

From what i understood from your code, you seem to be outputting the result after each input, i.e: 1 10 1 10 20 100 200 100 200 125 you should be doing this: 1 10 100 200 [EOF (^D)] 1 10 20 100 200 125 if you keep getting wrong answer, try submit-o-matic to submit your code instead of using e-mail.
by nightdog
Sun Jan 18, 2004 6:19 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 212009

help needed

i keep getting Time Exceeded, can anyone enlighten me on how to make the algorithm faster? [c] #include <stdio.h> #include <math.h> #include <stdlib.h> struct data { float i,j,result; struct data *next; }; int main() { float swap,i, j,input,result, maxcycle; struct data *start=NULL, *cur,*prev; whil...

Go to advanced search