結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー ecotteaecottea
提出日時 2022-10-19 02:03:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 625 bytes
コンパイル時間 1,052 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 88,004 KB
平均クエリ数 47.81
最終ジャッジ日時 2023-09-11 17:26:52
合計ジャッジ時間 27,600 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
87,212 KB
testcase_01 AC 277 ms
86,996 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 296 ms
87,332 KB
testcase_05 AC 337 ms
87,408 KB
testcase_06 AC 411 ms
87,672 KB
testcase_07 AC 273 ms
86,916 KB
testcase_08 AC 489 ms
86,920 KB
testcase_09 AC 467 ms
87,296 KB
testcase_10 AC 494 ms
87,524 KB
testcase_11 WA -
testcase_12 AC 789 ms
87,172 KB
testcase_13 AC 441 ms
87,616 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 938 ms
87,148 KB
testcase_17 AC 1,112 ms
87,328 KB
testcase_18 AC 1,175 ms
87,152 KB
testcase_19 WA -
testcase_20 TLE -
testcase_21 AC 1,096 ms
87,452 KB
testcase_22 WA -
testcase_23 AC 1,684 ms
86,568 KB
testcase_24 AC 1,310 ms
87,372 KB
testcase_25 AC 110 ms
87,488 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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271]

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