結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,472 KB
testcase_01 AC 65 ms
23,544 KB
testcase_02 AC 108 ms
23,456 KB
testcase_03 AC 108 ms
23,504 KB
testcase_04 AC 60 ms
23,616 KB
testcase_05 AC 60 ms
23,868 KB
testcase_06 AC 62 ms
23,668 KB
testcase_07 AC 60 ms
23,664 KB
testcase_08 AC 63 ms
23,552 KB
testcase_09 AC 63 ms
23,464 KB
testcase_10 AC 64 ms
23,592 KB
testcase_11 AC 82 ms
23,700 KB
testcase_12 AC 102 ms
23,680 KB
testcase_13 AC 62 ms
23,572 KB
testcase_14 AC 160 ms
23,516 KB
testcase_15 AC 168 ms
23,636 KB
testcase_16 AC 72 ms
23,876 KB
testcase_17 AC 76 ms
23,736 KB
testcase_18 AC 76 ms
23,484 KB
testcase_19 AC 165 ms
23,716 KB
testcase_20 AC 98 ms
24,144 KB
testcase_21 AC 75 ms
23,536 KB
testcase_22 AC 84 ms
23,568 KB
testcase_23 AC 84 ms
23,816 KB
testcase_24 AC 79 ms
23,992 KB
testcase_25 AC 56 ms
24,000 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>0: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