結果
| 問題 | No.8056 量子コンピュータで素因数分解 Easy |
| ユーザー |
emthrm
|
| 提出日時 | 2020-02-05 04:32:05 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 411 bytes |
| 記録 | |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 28,392 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-12-31 19:37:36 |
| 合計ジャッジ時間 | 5,158 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 RE * 25 |
ソースコード
import math
import random
n = int(input())
while True:
a = random.randint(2, n - 1)
g = math.gcd(a, n)
if g > 1:
print('! %d %d' % (g, n / g), flush = True)
break
print('? %d' % a, flush = True)
r = int(input())
if r % 2 == 1:
continue
p = math.gcd(pow(a, r / 2) + 1, n)
q = math.gcd(pow(a, r / 2) - 1, n)
if p < n and q < n:
print('! %d %d' % (p, q), flush = True)
break
emthrm