結果

問題 No.8056 量子コンピュータで素因数分解 Easy
ユーザー tatyam
提出日時 2020-02-04 18:16:41
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 363 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 359 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 35,584 KB
平均クエリ数 2.19
最終ジャッジ日時 2026-06-05 08:26:58
合計ジャッジ時間 7,522 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from random import randint
from sys import exit
from math import gcd
def answer(p):
    print('!', p, n // p)
    exit(0)
n = int(input())
while True:
    x = randint(2, n - 2)
    if gcd(n, x) > 1:
        answer(x)
    print('?', x, flush = True)
    r = int(input())
    if r % 2 == 0:
        p = pow(x, r // 2, n) + 1
        if p != n:
            answer(p)
0