結果

問題 No.8056 量子コンピュータで素因数分解 Easy
ユーザー kopricky
提出日時 2020-02-06 04:51:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 82,536 KB
実行使用メモリ 74,060 KB
平均クエリ数 3.04
最終ジャッジ日時 2024-12-31 19:59:19
合計ジャッジ時間 6,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys
N = int(input())
a = 1
while True:
    a += 1
    if N%a==0:
        print('!',a,N//a, flush=True)
        sys.exit(0)
    print('?',a, flush=True)
    p = int(input())
    if p%2==1:
        continue
    b = pow(a,p//2,N)+1
    if b == N:
        continue
    g = math.gcd(b, N)
    print('!',g,N//g, flush=True)
    sys.exit(0)
0