結果

問題 No.1140 EXPotentiaLLL!
コンテスト
ユーザー O2MT
提出日時 2020-12-06 12:50:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 408 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 577 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 313,852 KB
最終ジャッジ日時 2026-04-06 06:47:06
合計ジャッジ時間 7,375 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import sqrt
from itertools import accumulate
N = 5*(10**6)+1
l = [i for i in range(N)]
al = list(accumulate(l))
T = int(input())
for _ in range(T):
    A,P = map(int,input().split())
    flg = False
    for i in range(2,int(sqrt(P)+1)):
        if P%i == 0:
            flg = True
            break
    if flg:
        print(-1)
    else:
        a = A%P
        ans = a**al[P]%P
        print(ans)
0