結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
24,656 KB
testcase_01 AC 62 ms
24,992 KB
testcase_02 AC 117 ms
24,336 KB
testcase_03 AC 123 ms
25,004 KB
testcase_04 AC 62 ms
24,796 KB
testcase_05 AC 63 ms
24,340 KB
testcase_06 AC 66 ms
24,456 KB
testcase_07 AC 61 ms
24,552 KB
testcase_08 AC 70 ms
24,824 KB
testcase_09 AC 66 ms
25,152 KB
testcase_10 AC 66 ms
24,600 KB
testcase_11 AC 65 ms
24,788 KB
testcase_12 AC 100 ms
24,600 KB
testcase_13 AC 74 ms
24,664 KB
testcase_14 AC 70 ms
24,600 KB
testcase_15 AC 81 ms
25,048 KB
testcase_16 AC 97 ms
24,564 KB
testcase_17 AC 86 ms
25,092 KB
testcase_18 AC 83 ms
25,084 KB
testcase_19 AC 90 ms
25,084 KB
testcase_20 AC 106 ms
24,604 KB
testcase_21 AC 83 ms
25,020 KB
testcase_22 AC 78 ms
24,932 KB
testcase_23 AC 94 ms
24,988 KB
testcase_24 AC 87 ms
24,964 KB
testcase_25 AC 59 ms
24,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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