結果

問題 No.1140 EXPotentiaLLL!
ユーザー first_vilfirst_vil
提出日時 2020-07-31 22:04:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 441 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 134,924 KB
最終ジャッジ日時 2023-09-20 23:28:17
合計ジャッジ時間 19,258 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,841 ms
134,672 KB
testcase_01 WA -
testcase_02 AC 1,847 ms
134,704 KB
testcase_03 AC 1,415 ms
134,760 KB
testcase_04 AC 1,172 ms
134,692 KB
testcase_05 AC 1,592 ms
134,800 KB
testcase_06 AC 1,511 ms
134,804 KB
testcase_07 AC 1,901 ms
134,908 KB
testcase_08 AC 452 ms
134,660 KB
testcase_09 AC 443 ms
134,792 KB
testcase_10 AC 439 ms
134,672 KB
testcase_11 AC 455 ms
134,540 KB
testcase_12 AC 425 ms
134,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    p=[True]*5000001
    p[0]=p[1]=False
    i=2
    ps=[]
    while i<5000000:
        if p[i]:
            ps.append(i)
            j=i<<1
            while j<5000000:
                p[j]=False
                j+=i
        i+=1
    
    for _ in range(int(input())):
        a,b=map(int,input().split())
        if p[b]:
            print(pow(a%b,b-1,b))
        else:
            print(-1)
if __name__=='__main__':
    main()
0