Solve the Congruency

Given integers R,MR,M with M0M\neq 0, let S(R,M)S(R,M) denote the smallest positive integer xx satisfying the congruence Rx1(modM)Rx \equiv 1 \pmod{M} if such an xx exists. If such an xx does not exist, put S(R,M)=0S(R,M)=0.

Each line of this text file contains a pair of space separated integers representing RR and MM, respectively.

Let L be the list of integers whose kk-th element is the value of S(R,M)S(R,M), where RR and MM are taken from the kk-th line of the text file.

Let T be the sum of all elements of L. What are the last three digits of T?

×

Problem Loading...

Note Loading...

Set Loading...