Logo
(追記) (追記ここまで)

17603번 - Factorization 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 512 MB3281006625.095%

문제

Integer factorization serves an important role in many cryptography systems. It is about finding two positive integers p and q for a given positive composite number n such that n = pq and 1 < p ≤ q < n. However, it is a well-known NP-intermediate candidate. We still don’t have any algorithm to solve it in polynomial time.

Taylor, a number theorist, created another factorization problem as follows.

Given a prime number p and two integers a0, a1 ∈ {0, 1, . . . p − 1}. Find two integers b0, b1 ∈ {0, 1, . . . p − 1} such that a0 ≡ b0 · b1 (mod p) and a1 ≡ b0 + b1 (mod p).

“This factoring is way much cooler, in the sense that it can be computed efficiently,” said Taylor. Now, he invites you to enjoy this new variant of factorization.

입력

The first line contains an integer 1 ≤ T ≤ 100 indicating the number of test cases. For each test case, there is a line containing three non-negative integers p, a0, a1 separated by a single blank.

출력

For each test case, output a line containing b0 and b1 in ascending order separated by a single blank if b0 and b1 satisfy the equations. If there are multiple solutions, you may output any of them. If there is no solution, output −1.

제한

  • 1 ≤ T ≤ 100
  • 1 < p < 231 and p is a prime number.
  • a0, a1 ∈ {0, 1, . . . , p − 1}.

예제 입력 1

2
2 1 0
2 1 1

예제 출력 1

1 1
-1

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2019 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /