結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー PachicobuePachicobue
提出日時 2020-02-05 12:07:41
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 498 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 225,492 KB
平均クエリ数 0.08
最終ジャッジ日時 2023-08-30 06:50:24
合計ジャッジ時間 4,192 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
88,056 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import random
import sys
def power(x,n):
    if n==0:
        return 1
    elif n%2==1:
        return pow(x,n-1)*x
    else:
        return pow(x*x,n//2)
    
N = int(input())
if N%2==0:
    print('!',2,N//2)
    sys.exit(0)
while True:
    a = random.randint(2,N-1)
    g = math.gcd(a,N)
    if g!=1:
        print('!',g,N//g)
        sys.exit(0)
    print('?',a)
    p = int(input())
    b = power(a,p//2)+1
    if b!=N and N%b==0:
        print('!',b,N//b)
        sys.exit(0)
    
0