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

18745번 - Div 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB52131026.316%

문제

How many integers x > 0 exist such that c0xa0 + c1xa1 + . . . + cn−1xan−1 is divisible by x0 + x1 + . . . + xm−1?

입력

The first line contains a single integer t (1 ≤ t ≤ 105), denoting the number of test cases.

Each test case is described with two integers n and m (1 ≤ n ≤ 105; 1 ≤ m ≤ 109), followed by n lines containing a pair of integers ci and ai each (|ci| = 1; 0 ≤ ai ≤ 109).

The sum of n over all test cases does not exceed 105.

출력

For each test case, display the required number, or −1 if it is infinite.

제한

예제 입력 1

3
5 2
1 0
1 0
1 0
1 0
1 0
5 3
-1 2
-1 1
-1 0
1 1
-1 1
12 3
-1 0
-1 7
1 8
1 8
-1 4
-1 6
1 8
1 2
1 5
1 2
-1 9
1 5

예제 출력 1

1
-1
2

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 7: Gennady Korotkevich Contest 5 D번

Contest > Open Cup > 2019/2020 Season > Stage 11: Grand Prix of Gomel D번

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

출처

대학교 대회

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

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