結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
|
| 提出日時 | 2020-02-05 12:12:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 526 bytes |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 233,416 KB |
| 平均クエリ数 | 0.12 |
| 最終ジャッジ日時 | 2024-12-31 19:46:55 |
| 合計ジャッジ時間 | 74,062 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 2 TLE * 24 |
ソースコード
import math
import random
import sys
def power(x,n):
if n==0:
return 1
elif n%2==1:
return pow(x,n-1)*x
else:
return pow(x*x,n//2)
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())
b = power(a,p//2)+1
if b!=N and N%b==0:
print('!',b,N//b, flush=True)
sys.exit(0)