結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
23,664 KB
testcase_01 AC 68 ms
23,408 KB
testcase_02 AC 111 ms
23,396 KB
testcase_03 AC 111 ms
23,832 KB
testcase_04 AC 60 ms
23,752 KB
testcase_05 AC 61 ms
24,228 KB
testcase_06 AC 64 ms
23,864 KB
testcase_07 AC 63 ms
23,880 KB
testcase_08 AC 64 ms
23,700 KB
testcase_09 AC 66 ms
24,264 KB
testcase_10 AC 66 ms
23,608 KB
testcase_11 AC 84 ms
23,556 KB
testcase_12 AC 104 ms
24,064 KB
testcase_13 AC 64 ms
24,008 KB
testcase_14 AC 160 ms
23,972 KB
testcase_15 AC 171 ms
24,132 KB
testcase_16 AC 74 ms
24,024 KB
testcase_17 AC 78 ms
24,236 KB
testcase_18 AC 78 ms
23,568 KB
testcase_19 AC 165 ms
23,584 KB
testcase_20 AC 98 ms
23,512 KB
testcase_21 AC 77 ms
23,528 KB
testcase_22 AC 87 ms
23,656 KB
testcase_23 AC 85 ms
23,508 KB
testcase_24 AC 81 ms
23,944 KB
testcase_25 AC 59 ms
23,640 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>1 and g<n:break
	g=gcd(n,t+1)
	if g>1 and g<n:break
print("!",g,n//g)
0