結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー PachicobuePachicobue
提出日時 2020-02-05 13:52:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 88,660 KB
平均クエリ数 2.42
最終ジャッジ日時 2023-08-30 06:51:26
合計ジャッジ時間 7,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
88,128 KB
testcase_01 AC 130 ms
88,052 KB
testcase_02 AC 181 ms
87,636 KB
testcase_03 AC 194 ms
88,136 KB
testcase_04 AC 133 ms
88,060 KB
testcase_05 AC 132 ms
88,008 KB
testcase_06 AC 140 ms
87,772 KB
testcase_07 AC 130 ms
87,912 KB
testcase_08 AC 150 ms
87,916 KB
testcase_09 AC 132 ms
88,076 KB
testcase_10 AC 135 ms
88,164 KB
testcase_11 AC 133 ms
87,584 KB
testcase_12 AC 154 ms
87,684 KB
testcase_13 AC 146 ms
87,728 KB
testcase_14 AC 149 ms
88,224 KB
testcase_15 AC 149 ms
87,756 KB
testcase_16 AC 145 ms
87,724 KB
testcase_17 AC 145 ms
87,708 KB
testcase_18 AC 161 ms
88,192 KB
testcase_19 AC 169 ms
88,048 KB
testcase_20 AC 171 ms
87,892 KB
testcase_21 AC 145 ms
87,612 KB
testcase_22 AC 141 ms
87,916 KB
testcase_23 AC 161 ms
87,916 KB
testcase_24 AC 151 ms
88,472 KB
testcase_25 AC 124 ms
88,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import random
import sys
N = int(input())
if N%2==0:
    print('!',2,N//2, flush=True)
    sys.exit(0)
while True:
    a = random.randint(2,N-1)
    if N%a==0:
        print('!',a,N//a, flush=True)
        sys.exit(0)
    print('?',a, flush=True)
    p = int(input())
    if p%2==1:
        continue
    b = pow(a,p//2,N)+1
    if b == N:
        continue
    g = math.gcd(b, N)
    if g != 1:
        print('!',g,N//g, flush=True)
        sys.exit(0)
    
0