Since the point is searching for uniform distribution you should expect to get a lot of inputs with relative primes. If step and mod are relative primes the loop will iterate step-3 times.lotu wrote: Now more interstinglly if I change

[cpp] if( step % i == 0 && mod % i == 0)[/cpp]

Step may be up to 100000.

this will loop up to step only if both step and mod are prime otherwise at worst it will iterate min(sqrt(step),sqrt(mod)) times. sqrt(100000) is 316...lotu wrote: to:

[cpp] if( step % i == 0 || mod % i == 0)[/cpp]

both will loop up to the size of the variable if prime or up to its square root in the worst case otherwise.lotu wrote: or:

[cpp]if( step % i == 0)[/cpp]

or:

[cpp]if( mod % i == 0)[/cpp]

If judge's input is big enough and contains a lot of big relative primes it is easily seen that with the first test it may run >10x slower...lotu wrote:it dosen't time out any more and finshes in less than a second

Of course the code dosen't output the correct answer then.

So what is wrong?

Ciao!!!

Claudio