結果
問題 | No.414 衝動 |
ユーザー |
![]() |
提出日時 | 2022-11-03 10:48:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 66 ms / 1,000 ms |
コード長 | 1,130 bytes |
コンパイル時間 | 184 ms |
コンパイル使用メモリ | 82,780 KB |
実行使用メモリ | 60,572 KB |
最終ジャッジ日時 | 2024-07-17 21:10:08 |
合計ジャッジ時間 | 1,750 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 |
ソースコード
import randomdef is_prime3(q,k=50):q = abs(q)#計算するまでもなく判定できるものははじくif q == 2: return Trueif q < 2 or q&1 == 0: return False#n-1=2^s*dとし(但しaは整数、dは奇数)、dを求めるd = (q-1)>>1while d&1 == 0:d >>= 1#判定をk回繰り返すfor i in range(k):a = random.randint(1,q-1)t = dy = pow(a,t,q)#[0,s-1]の範囲すべてをチェックwhile t != q-1 and y != 1 and y != q-1:y = pow(y,2,q)t <<= 1if y != q-1 and t&1 == 0:return Falsereturn Truedef factorization(n):arr = []temp = nfor i in range(2, int(-(-n**0.5//1))+1):if temp%i==0:cnt=0while temp%i==0:cnt+=1temp //= iarr.append([i, cnt])if temp!=1:arr.append([temp, 1])if arr==[]:arr.append([n, 1])return arrn=int(input())if is_prime3(n)==True:print(1,n)else:print(factorization(n)[0][0],n//factorization(n)[0][0])