結果

問題 No.8056 量子コンピュータで素因数分解 Easy
ユーザー 👑 tatyam
提出日時 2020-02-04 18:16:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 363 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 28,312 KB
平均クエリ数 2.04
最終ジャッジ日時 2024-12-31 19:20:07
合計ジャッジ時間 5,459 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

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