結果

問題 No.1140 EXPotentiaLLL!
ユーザー first_vilfirst_vil
提出日時 2020-07-31 22:06:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 135,116 KB
最終ジャッジ日時 2023-09-20 23:32:31
合計ジャッジ時間 11,529 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 863 ms
135,016 KB
testcase_01 WA -
testcase_02 AC 884 ms
134,924 KB
testcase_03 AC 615 ms
134,920 KB
testcase_04 AC 589 ms
134,908 KB
testcase_05 AC 613 ms
134,864 KB
testcase_06 AC 606 ms
134,892 KB
testcase_07 AC 895 ms
134,924 KB
testcase_08 AC 395 ms
134,872 KB
testcase_09 AC 390 ms
134,712 KB
testcase_10 AC 372 ms
134,764 KB
testcase_11 AC 383 ms
134,716 KB
testcase_12 AC 373 ms
134,812 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