結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー 👑 MizarMizar
提出日時 2022-10-02 01:21:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 10,612 KB
実行使用メモリ 24,608 KB
平均クエリ数 3.04
最終ジャッジ日時 2023-08-30 07:01:16
合計ジャッジ時間 4,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
24,608 KB
testcase_01 AC 65 ms
23,920 KB
testcase_02 AC 107 ms
24,200 KB
testcase_03 AC 107 ms
24,024 KB
testcase_04 AC 57 ms
24,244 KB
testcase_05 AC 58 ms
24,440 KB
testcase_06 AC 60 ms
24,540 KB
testcase_07 AC 57 ms
23,844 KB
testcase_08 AC 61 ms
24,576 KB
testcase_09 AC 63 ms
24,148 KB
testcase_10 AC 62 ms
24,112 KB
testcase_11 AC 81 ms
23,852 KB
testcase_12 AC 102 ms
23,980 KB
testcase_13 AC 64 ms
24,136 KB
testcase_14 AC 163 ms
23,792 KB
testcase_15 AC 168 ms
24,220 KB
testcase_16 AC 71 ms
24,428 KB
testcase_17 AC 74 ms
24,228 KB
testcase_18 AC 75 ms
24,232 KB
testcase_19 AC 160 ms
24,256 KB
testcase_20 AC 96 ms
23,832 KB
testcase_21 AC 74 ms
24,412 KB
testcase_22 AC 84 ms
23,884 KB
testcase_23 AC 84 ms
24,156 KB
testcase_24 AC 78 ms
24,040 KB
testcase_25 AC 57 ms
24,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n = int(input()) # 合成数を入力
def check(v): # 出力チェック関数
    g = math.gcd(v, n)
    if g > 2 and g < n:
        print("!", g, n//g)
        exit()
for a in range(2, n-1): # a = {2,3,4,...,n-2}
    check(a) # 質問前にaをチェック
    print("?", a) # 位数を質問
    r = int(input()) # 位数の回答
    if r&1 == 0: # if r is even:
        check(pow(a, r>>1, n)-1) # pow(a, r//2) % n - 1
0