結果

問題 No.2324 Two Countries within UEC
ユーザー qibqib
提出日時 2023-05-29 20:46:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 78,720 KB
最終ジャッジ日時 2023-09-09 06:23:51
合計ジャッジ時間 13,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 386 ms
78,356 KB
testcase_01 AC 409 ms
78,532 KB
testcase_02 AC 166 ms
78,296 KB
testcase_03 AC 331 ms
78,552 KB
testcase_04 AC 352 ms
78,292 KB
testcase_05 AC 172 ms
78,288 KB
testcase_06 AC 208 ms
78,436 KB
testcase_07 AC 161 ms
78,264 KB
testcase_08 AC 321 ms
78,316 KB
testcase_09 AC 326 ms
78,284 KB
testcase_10 AC 413 ms
78,720 KB
testcase_11 AC 391 ms
78,288 KB
testcase_12 AC 201 ms
78,472 KB
testcase_13 AC 201 ms
78,668 KB
testcase_14 AC 165 ms
78,324 KB
testcase_15 AC 155 ms
78,100 KB
testcase_16 AC 313 ms
78,656 KB
testcase_17 AC 246 ms
78,516 KB
testcase_18 AC 166 ms
78,300 KB
testcase_19 AC 407 ms
78,492 KB
testcase_20 AC 147 ms
78,144 KB
testcase_21 AC 299 ms
78,644 KB
testcase_22 AC 352 ms
78,572 KB
testcase_23 AC 189 ms
78,552 KB
testcase_24 AC 315 ms
78,588 KB
testcase_25 AC 404 ms
78,540 KB
testcase_26 AC 319 ms
77,368 KB
testcase_27 AC 322 ms
77,360 KB
testcase_28 AC 322 ms
77,288 KB
testcase_29 AC 314 ms
77,352 KB
testcase_30 AC 316 ms
77,280 KB
testcase_31 AC 71 ms
71,208 KB
testcase_32 AC 71 ms
71,172 KB
testcase_33 AC 70 ms
71,164 KB
testcase_34 AC 73 ms
71,044 KB
testcase_35 AC 72 ms
71,264 KB
testcase_36 AC 73 ms
71,420 KB
testcase_37 AC 71 ms
71,004 KB
testcase_38 AC 72 ms
71,248 KB
testcase_39 AC 73 ms
71,164 KB
testcase_40 AC 72 ms
71,052 KB
testcase_41 AC 74 ms
71,244 KB
testcase_42 AC 73 ms
71,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, p, q = map(int, input().split())

for _ in range(q):
  x, f = map(int, input().split())
  if x % p == 0:
    if f == 0:
      print(m)
    else:
      print(0)
  else:
    y = (pow(x, p - 2, p) * f) % p
    lb = (1 - y + p - 1) // p
    ub = (m - y) // p
    print(max(0, ub - lb + 1))
0