12318 - Digital Roulette

Difficulty : easy

Solution Description :

Simple ad hoc problem

do this what is say in question but do not use pow() method for calculating xk
make a pow method 

long pow(long x, int k)
----if k==0 then return 1
----powval = x%(N+1)
----for i=1 to k-1 
------powval *= x
------powval  %= (N+1)

I use map<long,bool> for check dublicate
i.e. set mymap[calval]=true
and at the end print mymap.size()