結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
|
| 提出日時 | 2020-02-05 13:52:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 469 bytes |
| コンパイル時間 | 282 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 83,480 KB |
| 平均クエリ数 | 2.27 |
| 最終ジャッジ日時 | 2024-12-31 19:50:32 |
| 合計ジャッジ時間 | 5,432 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 RE * 2 |
ソースコード
import math
import random
import sys
N = int(input())
if N%2==0:
print('!',2,N//2, flush=True)
sys.exit(0)
while True:
a = random.randint(2,N-1)
if N%a==0:
print('!',a,N//a, flush=True)
sys.exit(0)
print('?',a, flush=True)
p = int(input())
if p%2==1:
continue
b = pow(a,p//2,N)+1
if b == N:
continue
g = math.gcd(b, N)
if g != 1:
print('!',g,N//g, flush=True)
sys.exit(0)