結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー ecotteaecottea
提出日時 2022-10-19 02:01:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 24,480 KB
平均クエリ数 24.15
最終ジャッジ日時 2023-09-11 17:24:32
合計ジャッジ時間 13,375 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
23,872 KB
testcase_01 AC 126 ms
23,736 KB
testcase_02 AC 1,248 ms
23,940 KB
testcase_03 AC 1,285 ms
23,408 KB
testcase_04 AC 135 ms
24,048 KB
testcase_05 AC 153 ms
23,832 KB
testcase_06 AC 183 ms
23,752 KB
testcase_07 AC 125 ms
24,408 KB
testcase_08 AC 217 ms
23,480 KB
testcase_09 AC 210 ms
24,124 KB
testcase_10 AC 220 ms
23,844 KB
testcase_11 WA -
testcase_12 AC 345 ms
23,700 KB
testcase_13 AC 200 ms
23,852 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 404 ms
23,592 KB
testcase_17 AC 483 ms
23,884 KB
testcase_18 AC 510 ms
23,704 KB
testcase_19 WA -
testcase_20 AC 1,016 ms
23,892 KB
testcase_21 AC 479 ms
23,888 KB
testcase_22 WA -
testcase_23 AC 733 ms
24,100 KB
testcase_24 AC 573 ms
23,812 KB
testcase_25 AC 58 ms
24,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())

a_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

ord_max = 0
a_max = -1

for a in a_list:
    if (n % a == 0):
        print("!", a, n // a)
        exit(0)

    print("?", a)

    r = int(input())

    if ord_max < r:
        ord_max = r
        a_max = a

pow_a = pow(a_max, ord_max // 2, mod=n)

p = math.gcd(pow_a + 1, n)
q = math.gcd(pow_a - 1, n)

print("!", p, q)
0