結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー 👑 MizarMizar
提出日時 2022-09-08 22:29:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 195 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 24,396 KB
平均クエリ数 3.04
最終ジャッジ日時 2023-08-30 06:58:51
合計ジャッジ時間 3,973 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,676 KB
testcase_01 AC 68 ms
23,772 KB
testcase_02 AC 111 ms
23,628 KB
testcase_03 AC 110 ms
23,516 KB
testcase_04 AC 61 ms
23,676 KB
testcase_05 AC 61 ms
23,828 KB
testcase_06 AC 62 ms
23,532 KB
testcase_07 AC 59 ms
23,732 KB
testcase_08 AC 63 ms
23,604 KB
testcase_09 AC 63 ms
23,612 KB
testcase_10 AC 65 ms
24,012 KB
testcase_11 AC 84 ms
23,416 KB
testcase_12 AC 107 ms
23,552 KB
testcase_13 AC 65 ms
23,500 KB
testcase_14 AC 160 ms
23,964 KB
testcase_15 AC 173 ms
23,616 KB
testcase_16 AC 73 ms
24,060 KB
testcase_17 AC 76 ms
24,012 KB
testcase_18 AC 79 ms
23,664 KB
testcase_19 AC 164 ms
24,396 KB
testcase_20 AC 95 ms
24,112 KB
testcase_21 AC 73 ms
23,716 KB
testcase_22 AC 83 ms
23,988 KB
testcase_23 AC 84 ms
23,576 KB
testcase_24 AC 81 ms
23,744 KB
testcase_25 AC 57 ms
24,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
n=int(input())
a=1
while a<n:
	a+=1
	g=gcd(n,a)
	if g>1:break
	print("?",a)
	r=int(input())
	t=pow(a,r//2,n)
	g=max(gcd(n,t-1)%n,gcd(n,t+1)%n)
	if g>1:break
print("!",g,n//g)
0