結果

問題 No.2324 Two Countries within UEC
ユーザー yu7400kiyu7400ki
提出日時 2023-05-28 14:32:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 14,548 KB
最終ジャッジ日時 2023-08-27 10:04:02
合計ジャッジ時間 37,521 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,734 ms
11,544 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1,504 ms
10,980 KB
testcase_05 WA -
testcase_06 AC 644 ms
9,448 KB
testcase_07 WA -
testcase_08 AC 1,382 ms
10,720 KB
testcase_09 AC 1,341 ms
10,728 KB
testcase_10 WA -
testcase_11 AC 1,798 ms
11,396 KB
testcase_12 AC 539 ms
9,272 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 276 ms
8,648 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 357 ms
9,160 KB
testcase_19 WA -
testcase_20 AC 230 ms
8,804 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 16 ms
7,736 KB
testcase_33 WA -
testcase_34 AC 16 ms
7,864 KB
testcase_35 AC 15 ms
7,816 KB
testcase_36 WA -
testcase_37 AC 16 ms
7,824 KB
testcase_38 AC 16 ms
7,756 KB
testcase_39 AC 16 ms
7,764 KB
testcase_40 WA -
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 = 0
    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