結果
| 問題 | No.8056 量子コンピュータで素因数分解 Easy |
| ユーザー |
emthrm
|
| 提出日時 | 2020-02-05 04:32:05 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 411 bytes |
| 記録 | |
| コンパイル時間 | 623 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 41,280 KB |
| 平均クエリ数 | 1.04 |
| 最終ジャッジ日時 | 2026-06-05 08:38:26 |
| 合計ジャッジ時間 | 11,047 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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