結果
| 問題 |
No.1232 2^x = x
|
| コンテスト | |
| ユーザー |
shakayami
|
| 提出日時 | 2020-11-26 20:33:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 671 ms / 2,000 ms |
| コード長 | 584 bytes |
| コンパイル時間 | 297 ms |
| コンパイル使用メモリ | 81,876 KB |
| 実行使用メモリ | 76,808 KB |
| 最終ジャッジ日時 | 2024-07-23 20:56:47 |
| 合計ジャッジ時間 | 2,409 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
from math import gcd
def phi(N):
M=N
prime=set()
p=2
while(p*p<=M):
while(M%p==0):
M//=p
prime.add(p)
p+=1
if M>1:
prime.add(M)
res=N
for p in prime:
res=(res*(p-1))//p
return res
def lcm(x,y):
return (x*y)//gcd(x,y)
def solve(A,M):
if pow(A,M,M)==0:
return M
if A==1:
return 1
if M==1:
return 1
phiM=phi(M)
x=solve(A,phiM)
L=lcm(phiM,M)
return pow(A,x,L)
Q=int(input())
for i in range(Q):
p=int(input())
print(solve(2,p))
shakayami