結果

問題 No.2119 一般化百五減算
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-11-04 22:35:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 94,628 KB
最終ジャッジ日時 2023-09-26 01:05:43
合計ジャッジ時間 3,840 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,300 KB
testcase_01 AC 67 ms
71,216 KB
testcase_02 AC 69 ms
71,144 KB
testcase_03 AC 68 ms
71,276 KB
testcase_04 AC 72 ms
75,700 KB
testcase_05 AC 70 ms
71,460 KB
testcase_06 AC 67 ms
71,400 KB
testcase_07 AC 69 ms
75,564 KB
testcase_08 AC 69 ms
71,432 KB
testcase_09 AC 67 ms
71,312 KB
testcase_10 AC 67 ms
71,440 KB
testcase_11 AC 69 ms
71,340 KB
testcase_12 AC 68 ms
71,348 KB
testcase_13 AC 67 ms
71,224 KB
testcase_14 AC 68 ms
71,360 KB
testcase_15 AC 66 ms
71,344 KB
testcase_16 AC 68 ms
71,388 KB
testcase_17 AC 66 ms
71,296 KB
testcase_18 AC 66 ms
71,404 KB
testcase_19 AC 66 ms
71,092 KB
testcase_20 AC 167 ms
89,776 KB
testcase_21 AC 70 ms
71,572 KB
testcase_22 AC 209 ms
91,756 KB
testcase_23 AC 198 ms
94,152 KB
testcase_24 AC 206 ms
94,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
m = int(input())
BC = []
dic = {}

for i in range(m):
    b,c = map(int,input().split())
    c %= b
    if b in dic and dic[b] != c:
        print("NaN")
        exit()
    dic[b] = c
    BC.append([b,c])

nums = [0]*(n+1)
for b,c in BC:
    for i in range(c,n+1,b):
        nums[i] += 1

le = len(BC)
for i in range(n+1):
    if nums[i] == le:
        print(i)
        exit()
print("NaN")
0