結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
|
| 提出日時 | 2020-01-28 01:26:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 154 ms / 2,000 ms |
| コード長 | 374 bytes |
| コンパイル時間 | 259 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 27,872 KB |
| 平均クエリ数 | 2.38 |
| 最終ジャッジ日時 | 2024-12-31 19:19:19 |
| 合計ジャッジ時間 | 5,253 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
import random
import math
n = int(input())
while True:
a = random.randint(2, n - 2)
b = math.gcd(n, a)
if b != 1:
print("!", b, n // b, flush=True)
break
print("?", a, flush=True)
r = int(input())
if r % 2 == 1:
continue
x = pow(a, r // 2, n)
if x == n - 1:
continue
p = math.gcd(n, x + 1)
print("!", p, n // p, flush=True)
break