結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー koprickykopricky
提出日時 2020-02-06 04:51:53
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 353 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 88,020 KB
平均クエリ数 3.04
最終ジャッジ日時 2023-08-30 06:53:24
合計ジャッジ時間 5,997 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
87,188 KB
testcase_01 AC 121 ms
87,388 KB
testcase_02 AC 163 ms
87,308 KB
testcase_03 AC 161 ms
87,788 KB
testcase_04 AC 116 ms
88,020 KB
testcase_05 AC 118 ms
86,948 KB
testcase_06 AC 118 ms
87,036 KB
testcase_07 AC 118 ms
87,156 KB
testcase_08 AC 117 ms
87,696 KB
testcase_09 AC 119 ms
87,136 KB
testcase_10 AC 116 ms
87,304 KB
testcase_11 AC 136 ms
87,532 KB
testcase_12 AC 159 ms
87,320 KB
testcase_13 AC 117 ms
86,956 KB
testcase_14 AC 215 ms
87,512 KB
testcase_15 AC 226 ms
87,632 KB
testcase_16 AC 124 ms
87,044 KB
testcase_17 AC 132 ms
87,108 KB
testcase_18 AC 130 ms
87,204 KB
testcase_19 AC 218 ms
87,512 KB
testcase_20 AC 154 ms
86,864 KB
testcase_21 AC 133 ms
87,332 KB
testcase_22 AC 140 ms
87,284 KB
testcase_23 AC 141 ms
86,984 KB
testcase_24 AC 134 ms
87,192 KB
testcase_25 AC 114 ms
87,264 KB
権限があれば一括ダウンロードができます

ソースコード

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