結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー 👑 tatyamtatyam
提出日時 2020-02-04 18:19:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 25,180 KB
平均クエリ数 2.31
最終ジャッジ日時 2023-08-30 06:43:45
合計ジャッジ時間 3,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
24,540 KB
testcase_01 AC 65 ms
24,800 KB
testcase_02 AC 118 ms
24,564 KB
testcase_03 AC 120 ms
24,716 KB
testcase_04 AC 64 ms
24,980 KB
testcase_05 AC 65 ms
24,812 KB
testcase_06 AC 70 ms
24,804 KB
testcase_07 AC 61 ms
24,328 KB
testcase_08 AC 88 ms
25,096 KB
testcase_09 AC 67 ms
25,020 KB
testcase_10 AC 69 ms
24,884 KB
testcase_11 AC 65 ms
25,180 KB
testcase_12 AC 72 ms
24,444 KB
testcase_13 AC 65 ms
24,624 KB
testcase_14 AC 70 ms
24,652 KB
testcase_15 AC 81 ms
24,384 KB
testcase_16 AC 75 ms
24,728 KB
testcase_17 AC 80 ms
24,528 KB
testcase_18 AC 82 ms
25,064 KB
testcase_19 AC 93 ms
24,600 KB
testcase_20 AC 105 ms
24,652 KB
testcase_21 AC 78 ms
24,884 KB
testcase_22 AC 72 ms
24,576 KB
testcase_23 AC 90 ms
24,880 KB
testcase_24 AC 85 ms
24,656 KB
testcase_25 AC 59 ms
24,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from random import randint
from sys import exit
from math import gcd
def answer(p):
    print('!', p, n // p)
    exit(0)
n = int(input())
while True:
    x = randint(2, n - 2)
    if gcd(n, x) > 1:
        answer(gcd(n, x))
    print('?', x, flush = True)
    r = int(input())
    if r % 2 == 0:
        p = pow(x, r // 2, n) + 1
        if p != n:
            answer(gcd(n, p))
0