結果
問題 | No.2324 Two Countries within UEC |
ユーザー | rts_tatsu |
提出日時 | 2023-05-28 16:00:28 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 747 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 10,984 KB |
実行使用メモリ | 28,192 KB |
最終ジャッジ日時 | 2023-08-27 13:38:06 |
合計ジャッジ時間 | 21,121 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,131 ms
27,324 KB |
testcase_01 | AC | 1,216 ms
28,176 KB |
testcase_02 | AC | 219 ms
12,004 KB |
testcase_03 | AC | 875 ms
23,184 KB |
testcase_04 | AC | 1,047 ms
25,368 KB |
testcase_05 | AC | 227 ms
12,144 KB |
testcase_06 | AC | 424 ms
15,204 KB |
testcase_07 | AC | 194 ms
11,300 KB |
testcase_08 | AC | 1,013 ms
23,404 KB |
testcase_09 | AC | 951 ms
23,908 KB |
testcase_10 | AC | 1,233 ms
28,124 KB |
testcase_11 | AC | 1,218 ms
28,192 KB |
testcase_12 | AC | 377 ms
14,248 KB |
testcase_13 | AC | 359 ms
14,560 KB |
testcase_14 | AC | 222 ms
12,136 KB |
testcase_15 | AC | 200 ms
11,488 KB |
testcase_16 | AC | 820 ms
21,724 KB |
testcase_17 | AC | 526 ms
16,816 KB |
testcase_18 | AC | 246 ms
12,196 KB |
testcase_19 | AC | 1,212 ms
28,080 KB |
testcase_20 | AC | 168 ms
11,048 KB |
testcase_21 | TLE | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
ソースコード
def extended_gcd(a, b): if b == 0: return a, 1, 0 else: d, x, y = extended_gcd(b, a % b) return d, y, x - (a // b) * y def count_valid_y(n, m, x, p, f): d, _, _ = extended_gcd(x, p) if f % d != 0: return 0 else: p_div_d = p // d f_div_d = f // d y0 = (f_div_d * extended_gcd(x // d, p_div_d)[1]) % p_div_d count = 0 for k in range((m - y0) // p_div_d + 1): y = y0 + k * p_div_d if 1 <= y <= m: count += 1 return count N, M, P, Q = map(int, input().split()) queries = [list(map(int, input().split())) for _ in range(Q)] for x, f in queries: result = count_valid_y(N, M, x, P, f) print(result)