結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
24,052 KB
testcase_01 AC 66 ms
24,336 KB
testcase_02 AC 111 ms
23,524 KB
testcase_03 AC 108 ms
23,788 KB
testcase_04 AC 59 ms
23,964 KB
testcase_05 AC 59 ms
23,632 KB
testcase_06 AC 61 ms
23,804 KB
testcase_07 AC 58 ms
23,628 KB
testcase_08 AC 63 ms
24,492 KB
testcase_09 AC 63 ms
23,740 KB
testcase_10 AC 62 ms
23,672 KB
testcase_11 AC 80 ms
23,760 KB
testcase_12 AC 102 ms
23,876 KB
testcase_13 AC 62 ms
24,264 KB
testcase_14 AC 160 ms
23,616 KB
testcase_15 AC 172 ms
23,872 KB
testcase_16 AC 70 ms
24,048 KB
testcase_17 AC 74 ms
23,740 KB
testcase_18 AC 75 ms
24,312 KB
testcase_19 AC 165 ms
23,628 KB
testcase_20 AC 96 ms
23,560 KB
testcase_21 AC 73 ms
24,312 KB
testcase_22 AC 83 ms
24,252 KB
testcase_23 AC 85 ms
23,672 KB
testcase_24 AC 79 ms
24,348 KB
testcase_25 AC 56 ms
23,668 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())
	if r%2==1:continue
	t=pow(a,r//2,n)
	g=gcd(n,t-1)
	if g%n>1:break
	g=gcd(n,t+1)
	if g%n>1:break
print("!",g,n//g)
0