結果
問題 |
No.8056 量子コンピュータで素因数分解 Easy
|
ユーザー |
👑 ![]() |
提出日時 | 2020-02-04 18:19:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 172 ms / 2,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 28,000 KB |
平均クエリ数 | 2.42 |
最終ジャッジ日時 | 2024-12-31 19:20:30 |
合計ジャッジ時間 | 5,317 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
from random import randint from sys import exit from math import gcd def answer(p): print('!', p, n // p) exit(0) n = int(input()) while True: x = randint(2, n - 2) if gcd(n, x) > 1: answer(gcd(n, x)) print('?', x, flush = True) r = int(input()) if r % 2 == 0: p = pow(x, r // 2, n) + 1 if p != n: answer(gcd(n, p))