結果
問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
ユーザー |
👑 |
提出日時 | 2022-09-07 20:20:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 181 ms / 2,000 ms |
コード長 | 316 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 28,248 KB |
平均クエリ数 | 2.58 |
最終ジャッジ日時 | 2024-12-31 20:14:11 |
合計ジャッジ時間 | 4,848 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import math import random n=int(input()) g=0 while True: a=random.randrange(2,n-1) g=math.gcd(n,a) if g>1: break print("?",a) r=int(input()) if r%2==1: continue r//=2 m=pow(a,r,n) p=(m-1)%n g=math.gcd(n,p) if p>0 and g>1: break q=(m+1)%n g=math.gcd(n,q) if q>0 and g>1: break print("!",g,n//g)