結果

問題 No.2324 Two Countries within UEC
ユーザー yu7400kiyu7400ki
提出日時 2023-05-28 14:34:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 14,576 KB
最終ジャッジ日時 2023-08-27 10:07:09
合計ジャッジ時間 33,277 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,732 ms
11,660 KB
testcase_01 AC 1,286 ms
11,552 KB
testcase_02 AC 140 ms
9,136 KB
testcase_03 AC 736 ms
10,824 KB
testcase_04 AC 1,494 ms
11,024 KB
testcase_05 AC 299 ms
9,168 KB
testcase_06 AC 615 ms
9,516 KB
testcase_07 AC 211 ms
8,712 KB
testcase_08 AC 1,338 ms
10,748 KB
testcase_09 AC 1,352 ms
10,860 KB
testcase_10 AC 916 ms
11,548 KB
testcase_11 AC 1,729 ms
11,448 KB
testcase_12 AC 565 ms
9,196 KB
testcase_13 AC 491 ms
9,284 KB
testcase_14 AC 147 ms
9,028 KB
testcase_15 AC 272 ms
8,716 KB
testcase_16 AC 642 ms
10,492 KB
testcase_17 AC 568 ms
9,820 KB
testcase_18 AC 334 ms
9,016 KB
testcase_19 AC 839 ms
11,484 KB
testcase_20 AC 234 ms
8,876 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,165 ms
11,584 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 15 ms
7,864 KB
testcase_32 AC 15 ms
7,780 KB
testcase_33 AC 15 ms
7,764 KB
testcase_34 AC 16 ms
7,760 KB
testcase_35 AC 16 ms
7,808 KB
testcase_36 AC 15 ms
7,780 KB
testcase_37 AC 16 ms
7,876 KB
testcase_38 AC 16 ms
7,808 KB
testcase_39 AC 16 ms
7,820 KB
testcase_40 AC 15 ms
7,860 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
    if y > M:
        ans.append(0)
        continue
    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