結果

問題 No.2119 一般化百五減算
ユーザー とりゐとりゐ
提出日時 2022-11-04 21:30:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 79,040 KB
最終ジャッジ日時 2023-09-25 23:43:14
合計ジャッジ時間 3,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
76,372 KB
testcase_01 AC 76 ms
76,236 KB
testcase_02 AC 77 ms
76,352 KB
testcase_03 AC 78 ms
76,476 KB
testcase_04 AC 78 ms
76,236 KB
testcase_05 AC 77 ms
76,340 KB
testcase_06 AC 77 ms
76,392 KB
testcase_07 AC 76 ms
76,348 KB
testcase_08 AC 77 ms
76,296 KB
testcase_09 AC 77 ms
76,320 KB
testcase_10 AC 78 ms
76,332 KB
testcase_11 AC 79 ms
76,304 KB
testcase_12 AC 76 ms
76,248 KB
testcase_13 AC 76 ms
76,240 KB
testcase_14 AC 75 ms
76,412 KB
testcase_15 AC 76 ms
76,436 KB
testcase_16 AC 76 ms
76,340 KB
testcase_17 AC 76 ms
76,336 KB
testcase_18 AC 77 ms
76,340 KB
testcase_19 AC 78 ms
76,356 KB
testcase_20 AC 143 ms
78,776 KB
testcase_21 AC 76 ms
72,108 KB
testcase_22 AC 160 ms
78,952 KB
testcase_23 AC 159 ms
78,800 KB
testcase_24 AC 164 ms
79,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
m=int(input())
M=10**5+10
bc=[-1]*M
cnt=0
for i in range(m):
  b,c=map(int,input().split())
  c%=b
  if bc[b]==-1:
    bc[b]=c
    cnt+=1
  else:
    if bc[b]!=c:
      print('NaN')
      exit()

ok=[0]*(n+1)
for i in range(M):
  if bc[i]!=-1:
    tmp=bc[i]
    while tmp<=n:
      ok[tmp]+=1
      tmp+=i

for i in range(n+1):
  if ok[i]==cnt:
    print(i)
    exit()

print('NaN')
0