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
Search found 10 matches
- Mon Jul 19, 2004 6:43 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
- Sun Feb 15, 2004 5:40 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
- Sun Feb 15, 2004 5:39 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
- Sat Feb 14, 2004 5:09 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
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 ...
- Fri Feb 06, 2004 12:41 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
- Thu Jan 29, 2004 6:01 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
- Tue Jan 27, 2004 1:26 am
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
congratz dude!
good luck with the next problem 

- Fri Jan 23, 2004 4:56 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
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 ...
you can either submit your code using the e-mail you specified when you subscribed or change that parameter, which can be done by ...
- Thu Jan 22, 2004 5:54 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
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 ...
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 ...
- Sun Jan 18, 2004 6:19 pm
- Forum: Volume 1 (100-199)
- Topic: 100 - The 3n + 1 problem
- Replies: 1394
- Views: 317957
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 ...
[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 ...