結果

問題 No.2324 Two Countries within UEC
ユーザー navel_tosnavel_tos
提出日時 2023-05-29 17:33:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 587 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 83,096 KB
最終ジャッジ日時 2023-09-09 06:23:12
合計ジャッジ時間 15,837 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 490 ms
79,500 KB
testcase_01 AC 545 ms
79,684 KB
testcase_02 AC 226 ms
78,828 KB
testcase_03 AC 407 ms
79,188 KB
testcase_04 AC 442 ms
78,964 KB
testcase_05 AC 278 ms
80,672 KB
testcase_06 AC 280 ms
79,372 KB
testcase_07 AC 273 ms
80,516 KB
testcase_08 AC 406 ms
79,100 KB
testcase_09 AC 437 ms
78,984 KB
testcase_10 AC 504 ms
79,096 KB
testcase_11 AC 587 ms
83,096 KB
testcase_12 AC 250 ms
78,964 KB
testcase_13 AC 249 ms
78,928 KB
testcase_14 AC 205 ms
79,200 KB
testcase_15 AC 198 ms
79,116 KB
testcase_16 AC 399 ms
79,924 KB
testcase_17 AC 298 ms
79,120 KB
testcase_18 AC 209 ms
78,956 KB
testcase_19 AC 495 ms
79,188 KB
testcase_20 AC 195 ms
79,480 KB
testcase_21 AC 512 ms
81,584 KB
testcase_22 AC 453 ms
79,552 KB
testcase_23 AC 328 ms
81,188 KB
testcase_24 AC 444 ms
80,196 KB
testcase_25 AC 521 ms
79,540 KB
testcase_26 AC 339 ms
78,540 KB
testcase_27 AC 340 ms
78,512 KB
testcase_28 AC 332 ms
78,764 KB
testcase_29 AC 337 ms
78,848 KB
testcase_30 AC 335 ms
78,784 KB
testcase_31 AC 72 ms
71,404 KB
testcase_32 AC 70 ms
71,280 KB
testcase_33 AC 72 ms
71,084 KB
testcase_34 AC 70 ms
71,336 KB
testcase_35 AC 70 ms
71,468 KB
testcase_36 AC 69 ms
71,340 KB
testcase_37 AC 70 ms
71,212 KB
testcase_38 AC 74 ms
71,420 KB
testcase_39 AC 72 ms
71,388 KB
testcase_40 AC 70 ms
71,612 KB
testcase_41 AC 70 ms
71,420 KB
testcase_42 AC 72 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#MMA Contest 015 C

'''
xが与えられるので、x*y mod P≡f となるyの個数を出力せよ。

急に緑diff。
絶対に初心者向けではない。難しすぎる。
'''
gcd=lambda x,y: gcd(y,x%y) if x%y else y
f=lambda:list(map(int,input().split()))

N,M,P,Q=f()
for _ in range(Q):
    x,a=f()
    if a>=P: print(0); continue
    Z=gcd(x,P)
    if a%Z: print(0); continue
    nX=x//Z; nP=P//Z; nA=a//Z
    revX=pow(nX,nP-2,nP)
    basic=revX*nA%nP
    ans=(M-basic)//nP-1
    while (ans+1)*nP<=M-basic: ans+=1
    if a==0: print(ans)
    else: print(ans+1)
0