結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
23,928 KB
testcase_01 AC 66 ms
24,192 KB
testcase_02 AC 109 ms
24,088 KB
testcase_03 AC 110 ms
24,336 KB
testcase_04 AC 63 ms
23,484 KB
testcase_05 AC 63 ms
23,596 KB
testcase_06 AC 63 ms
23,540 KB
testcase_07 AC 61 ms
24,220 KB
testcase_08 AC 66 ms
24,264 KB
testcase_09 AC 65 ms
24,156 KB
testcase_10 AC 66 ms
23,672 KB
testcase_11 AC 84 ms
24,204 KB
testcase_12 AC 106 ms
23,992 KB
testcase_13 AC 64 ms
23,800 KB
testcase_14 AC 163 ms
24,228 KB
testcase_15 AC 170 ms
23,832 KB
testcase_16 AC 75 ms
23,788 KB
testcase_17 AC 79 ms
23,732 KB
testcase_18 AC 77 ms
24,132 KB
testcase_19 AC 165 ms
23,612 KB
testcase_20 AC 98 ms
24,240 KB
testcase_21 AC 77 ms
24,228 KB
testcase_22 AC 87 ms
23,588 KB
testcase_23 AC 86 ms
23,460 KB
testcase_24 AC 80 ms
23,608 KB
testcase_25 AC 59 ms
23,488 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=max(gcd(n,t-1)%n,gcd(n,t+1)%n)
	if g>1:break
print("!",g,n//g)
0