Re: 10754 - Fantastic Sequence
Posted: Wed Jul 06, 2011 10:49 pm
Nice problem (it was a tougher one for me).
I used this mod function for handling negative numbers:
I used this mod function for handling negative numbers:
Code: Select all
i64 mod(i64 a,i64 m)
{
if(a>0) return a%m;
if(a==0) return 0;
a=a*-1;
i64 M=a%m;
if(M==0) return 0;
return m-M;
}