Comments
0

I solved problem E afterwards with help of OEIS. During the contest, I was pretty messed up with that. Anyone would like to care what I am thinking wrong for Problem E. If I am not wrong there was two announcements. There was that thing, [1, 3, 4, 2] and [4, 2, 1, 3] are equal (in first announcement), [1, 2, 3] and [1, 3, 2] are distinguishable (in second announcement). My question is, I can make [1, 3, 2] from the [1, 2, 3] by choosing 1 (index 1) then going backwards index 3 with value 3 and index 2 with value 2, thus it makes [1, 3, 2]. So [1, 2, 3] and [1, 3, 2] circle should be equal like [1, 3, 4, 2] and [4, 2, 1, 3]. What is wrong with my thinking?

Nice. But if the range of x is: 0 <= x < 2m Then Euler Phi does not work I guess. Like if a=8, m=12 and for 0<=x <m , The answer is 2 like Phi(3) but for 0 <=x <2m , answer is 4 i guess. Which is not Phi(3) but it is 2*Phi(3). Also if x was: 0 <=x <= 2m , Then the answer is 5. I don't know how to explain that. But if you see, for ==> gcd(a+x,m) = gcd((a+x)%m),m) (according to many comments) which says that no matter what is x's range, we only need to find the Phi(m/gcd(a,m)) which is incorrect for x's various range.