結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 105 ms
23,884 KB
testcase_03 AC 106 ms
23,672 KB
testcase_04 AC 59 ms
23,988 KB
testcase_05 AC 57 ms
24,308 KB
testcase_06 AC 60 ms
23,808 KB
testcase_07 AC 57 ms
23,856 KB
testcase_08 AC 61 ms
24,288 KB
testcase_09 AC 61 ms
23,684 KB
testcase_10 AC 62 ms
23,728 KB
testcase_11 WA -
testcase_12 AC 90 ms
23,988 KB
testcase_13 AC 63 ms
23,784 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 69 ms
23,988 KB
testcase_17 AC 72 ms
23,996 KB
testcase_18 AC 74 ms
23,884 KB
testcase_19 WA -
testcase_20 AC 95 ms
23,640 KB
testcase_21 AC 72 ms
24,252 KB
testcase_22 WA -
testcase_23 AC 82 ms
23,732 KB
testcase_24 AC 76 ms
23,640 KB
testcase_25 AC 54 ms
24,420 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]

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

    print("?", a)

    r = int(input())

    if r % 2 == 1:
        continue

    pow_a = pow(a, r // 2, mod=n)

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

    print("!", p, q)
    break
0