I don't agree with you, Zhao Le. I always read only actual case(in all problems), compute answer and output it. I got problem 100 in the same way, so I think that's no bug in it . I've got Accepted over 500 problems so I think, that you don't have right ...
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Both of codes looks similar ...
Did you try to compile it both and check if both of them give you the same results in all cases ?? many is small mistake in one of them ?
I don't know - if I will have time, I try to check it ....
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
I'm sure there's something simple I'm missing me that's giving me a wrong answer...
[cpp]
#include <iostream.h>
void main()
{
int i, j,total=0, ti, tj, temp,max=0, t;
while(cin >> i >> j)
{
// which is larger
if (i > j)
{
t = i;
i = j;
j = t;
}
ti = i; tj=j, temp=0;
for (int x = i; x <= j; x++ )
{
temp = x;
while (temp != 1)
{
if (temp%2 == 0)
{
temp/=2;
total++;
} else
{
temp*=3;
temp++;
total++;
}
}
if (total > max)
max = ++total;
total = 0;
}
cout << ti << " " << tj << " " << max << endl;
max = 0;
}
}
[/cpp]
if like this, when total = max, you cannot put into max. I mean like this :
if total = 10 so cycle lenght is 11 ( base on your code ). if max = 10, so cycle lenght max = 10 not 11. and the true answer cycle lenght max = 11.
I don't know either. You can see my submission got AC (and it was a copy-and-paste submission of your first code).
Anyway, please note down the full submission number when you find this kind of things as we can retrieve your submissions and try to find out what happens.
the output must have the same sequence as the input was... so you musn't swap them, but instead you can use other variables to store their values temporarily
While in your second code, you've done this by storing the actual value in the linked list, that's why the second got accepted
some other programmers use function with parameter, which does similarly the same idea
the output must have the same sequence as the input was... so you musn't swap them, but instead you can use other variables to store their values temporarily
While in your second code, you've done this by storing the actual value in the linked list, that's why the second got accepted
some other programmers use function with parameter, which does similarly the same idea