fack's blog

By fack, history, 4 years ago, In English

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?

  • Vote: I like it
  • -52
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can you give a link to the problem?

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +16 Vote: I do not like it

    I think this is from an active contest, so please don't answer this question.