結果

問題 No.2119 一般化百五減算
ユーザー H3PO4H3PO4
提出日時 2022-11-05 08:38:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 85,984 KB
最終ジャッジ日時 2023-09-26 09:17:54
合計ジャッジ時間 4,522 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,548 KB
testcase_01 AC 78 ms
75,828 KB
testcase_02 AC 78 ms
75,888 KB
testcase_03 AC 78 ms
75,728 KB
testcase_04 AC 80 ms
76,080 KB
testcase_05 AC 79 ms
75,616 KB
testcase_06 AC 79 ms
75,908 KB
testcase_07 AC 79 ms
75,712 KB
testcase_08 AC 82 ms
75,864 KB
testcase_09 AC 79 ms
75,940 KB
testcase_10 AC 81 ms
75,804 KB
testcase_11 AC 80 ms
75,596 KB
testcase_12 AC 82 ms
75,616 KB
testcase_13 AC 80 ms
75,912 KB
testcase_14 AC 80 ms
75,600 KB
testcase_15 AC 78 ms
75,860 KB
testcase_16 AC 78 ms
75,908 KB
testcase_17 AC 79 ms
75,852 KB
testcase_18 AC 79 ms
75,888 KB
testcase_19 AC 80 ms
75,632 KB
testcase_20 WA -
testcase_21 AC 101 ms
81,236 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline


def solve(N, M, V):
    MAX = 10 ** 5
    mod_table = [None] * (MAX + 1)
    for c, b in V:
        if mod_table[b] is None:
            mod_table[b] = c
        elif mod_table[b] != c:
            return "NaN"
    res_table = [0] * (N + 1)
    for i, mod in enumerate(mod_table):
        if mod is None:
            continue
        for x in range(mod, N + 1, i):
            res_table[x] += 1
    for i in range(N + 1):
        if res_table[i] == M:
            return i
    return "NaN"


N = int(input())
M = int(input())
V = []
for _ in range(M):
    b, c = map(int, input().split())
    c %= b
    V.append((c, b))
print(solve(N, M, V))
0