結果

問題 No.1140 EXPotentiaLLL!
ユーザー first_vilfirst_vil
提出日時 2020-07-31 22:08:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 892 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 134,992 KB
最終ジャッジ日時 2023-09-20 23:35:34
合計ジャッジ時間 10,614 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 892 ms
134,768 KB
testcase_01 AC 598 ms
134,716 KB
testcase_02 AC 860 ms
134,668 KB
testcase_03 AC 590 ms
134,992 KB
testcase_04 AC 540 ms
134,900 KB
testcase_05 AC 614 ms
134,876 KB
testcase_06 AC 594 ms
134,780 KB
testcase_07 AC 892 ms
134,784 KB
testcase_08 AC 393 ms
134,872 KB
testcase_09 AC 395 ms
134,892 KB
testcase_10 AC 394 ms
134,724 KB
testcase_11 AC 356 ms
134,784 KB
testcase_12 AC 378 ms
134,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline

    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