Also, you can probably optimized a thing or two here, since the first time I got AC, I don't think I cache anything, so you just have to be careful, like:
err.....need help...i think that i have made all possible adjustment ..
but i still get the over limit (10.47 seconds..)....confused where's wrong..??
can anybody give me a hint??
#include<stdio.h>
int main(){
long int l,u,i,x,max,y,z;
int sequence[1000];
helo
think of input like:
1 100
1 101
1 102
1 103
1 1000
1 2000
...
computing the cycle length
more than once leads to
inefficiency . you need a
big array ( say size of 100000 ) ,
fill it up with the
cycle lengths . use brute force or
be careful and try to use that
cyc. len ( 2 * n ) =
1 + cyc. len. ( n )
and
1 + cyc. len. ( 3 * n + 1 ) =
cyc. len. ( n )
bye
emm..i see your point..
then i try to change my program as follow....
but i got runtime error : invalid memory reference...
is it because of the size of array isn't enough or something else??
#include<stdio.h>
int main(){
long int l,u,i,x,max,y,angka;
int sequence[100000];
helo
please fill up the
array 'sequence' before
the processing of input ...
... if you need the cycle
length of a number >= 100000
then begin to generate the
sequence until you reach a
number < 100000 . then
cyclen of this num +
num of steps is ...
bye
No sajid he will fell again in TL problem if he made that correct.
The best solution of the prolem is decreasing unimportant works
that he did.
Most person who solved the problem that i know have faced the
TLE at least 3 to 10 times
So, its really tricky one to solve in margin line
Tanzim, your algo like mine, but I think your TLE because you use Long int for this problem is not corect, because if the odd number like n= 3212345541 3*n+1 can be larger than 2^32 and produce negative result and this is can make looping forever. you can use double and fmod for this problem.