結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
24,128 KB
testcase_01 AC 66 ms
23,672 KB
testcase_02 AC 109 ms
23,756 KB
testcase_03 AC 108 ms
23,752 KB
testcase_04 AC 61 ms
23,740 KB
testcase_05 AC 60 ms
24,036 KB
testcase_06 AC 60 ms
23,484 KB
testcase_07 AC 58 ms
23,692 KB
testcase_08 AC 64 ms
23,664 KB
testcase_09 AC 63 ms
23,568 KB
testcase_10 AC 63 ms
24,336 KB
testcase_11 AC 81 ms
23,952 KB
testcase_12 AC 103 ms
24,244 KB
testcase_13 AC 62 ms
23,800 KB
testcase_14 AC 163 ms
24,324 KB
testcase_15 AC 171 ms
24,312 KB
testcase_16 AC 73 ms
24,348 KB
testcase_17 AC 80 ms
24,012 KB
testcase_18 AC 80 ms
23,808 KB
testcase_19 AC 168 ms
23,532 KB
testcase_20 AC 99 ms
23,828 KB
testcase_21 AC 76 ms
23,528 KB
testcase_22 AC 83 ms
24,348 KB
testcase_23 AC 85 ms
23,792 KB
testcase_24 AC 78 ms
24,100 KB
testcase_25 AC 55 ms
23,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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