結果
| 問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
| ユーザー |
👑 |
| 提出日時 | 2022-10-02 01:31:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 2,000 ms |
| コード長 | 619 bytes |
| コンパイル時間 | 264 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 27,872 KB |
| 平均クエリ数 | 1.96 |
| 最終ジャッジ日時 | 2024-12-31 20:24:12 |
| 合計ジャッジ時間 | 4,897 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
import math # 数学ライブラリ(最大公約数(greatest common divisor, gcd))のため
n = int(input()) # 合成数 n を取得
def check(v): # 出力チェック関数
g = math.gcd(v, n)
if g > 2 and g < n:
print("!", g, n//g)
exit()
check(3) # 3の素因数をチェック
for a in range(2, n-1): # a = {2,3,4,...,n-2}
check(a) # 質問前にaをチェック
print("?", a) # 位数を質問
r = int(input()) # 位数の回答
if r&1 == 0: # if r is even:
r >>= 1
for b in range(99): # b = {0,1,2,...,98}
check(pow(a+b, r, n)-1) # pow(a + b, r) % n - 1