How to Modular Equations Efficienty?

Правка en1, от fack, 2020-12-10 09:10:51

So, I am doing a Question which I am able to reduce to the following problem :-

EQ1:- C2 = (a2^2)%P EQ2:- C2+C1 = ((a1+a2)^2)%P

find any one pair (a1,a2) satisfying above equations where P is prime number >=3 and C1 and C2 are integer between >=0 and <P.

constraints:- 1) P < 1e9+9 2) TestCases(T) <= 1e4 3) TimeLimit 4s

My approached (basically trying to find sqareroot modulus) 1) bruteforces over each value from 0 to P/2 and store squareroot modulus but that's O(T*P) 2) Tonelli–Shanks algorithm but that also is getting TLE

How to solve above equation efficiency?

Теги #modular arithmetic, #equation, square

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский fack 2020-12-10 09:12:43 31
en2 Английский fack 2020-12-10 09:11:22 5 Tiny change: '(a2^2)%P\nEQ2:- C2' -> '(a2^2)%P\n\n\nEQ2:- C2'
en1 Английский fack 2020-12-10 09:10:51 654 Initial revision (published)