結果

問題 No.2324 Two Countries within UEC
ユーザー yu7400kiyu7400ki
提出日時 2023-05-28 14:40:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 1,236 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 83,296 KB
最終ジャッジ日時 2023-08-27 10:18:34
合計ジャッジ時間 9,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
82,752 KB
testcase_01 AC 250 ms
83,296 KB
testcase_02 AC 118 ms
78,284 KB
testcase_03 AC 200 ms
82,652 KB
testcase_04 AC 214 ms
81,092 KB
testcase_05 AC 124 ms
78,120 KB
testcase_06 AC 143 ms
79,860 KB
testcase_07 AC 113 ms
77,388 KB
testcase_08 AC 196 ms
81,076 KB
testcase_09 AC 198 ms
80,828 KB
testcase_10 AC 246 ms
82,892 KB
testcase_11 AC 235 ms
83,184 KB
testcase_12 AC 139 ms
79,144 KB
testcase_13 AC 144 ms
79,684 KB
testcase_14 AC 123 ms
78,348 KB
testcase_15 AC 117 ms
77,560 KB
testcase_16 AC 195 ms
81,784 KB
testcase_17 AC 161 ms
80,916 KB
testcase_18 AC 121 ms
78,248 KB
testcase_19 AC 237 ms
83,020 KB
testcase_20 AC 111 ms
77,388 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 241 ms
82,868 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 74 ms
71,336 KB
testcase_32 AC 73 ms
71,400 KB
testcase_33 AC 72 ms
71,196 KB
testcase_34 AC 73 ms
71,264 KB
testcase_35 AC 73 ms
71,460 KB
testcase_36 AC 72 ms
71,284 KB
testcase_37 AC 73 ms
71,416 KB
testcase_38 AC 71 ms
71,208 KB
testcase_39 AC 73 ms
71,336 KB
testcase_40 AC 73 ms
71,456 KB
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, P, Q = map(int, input().split())

def mod_div(a, b, p):
    return (a * pow(b, p - 2, p)) % p

ans = []
for _ in range(Q):
    x, f = map(int, input().split())
    y = mod_div(f, x, P)
    if y == 0:
        y = P
    ok = -1
    ng = M
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if P * mid + y <= M:
            ok = mid
        else:
            ng = mid
    ans.append(ok + 1)

print(*ans, sep="\n")
0