結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー Ryuhei MoriRyuhei Mori
提出日時 2020-01-28 01:26:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 10,644 KB
実行使用メモリ 25,168 KB
平均クエリ数 2.38
最終ジャッジ日時 2023-08-30 06:43:06
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
25,156 KB
testcase_01 AC 61 ms
24,996 KB
testcase_02 AC 118 ms
24,476 KB
testcase_03 AC 119 ms
24,660 KB
testcase_04 AC 63 ms
25,056 KB
testcase_05 AC 65 ms
24,928 KB
testcase_06 AC 67 ms
24,616 KB
testcase_07 AC 63 ms
24,656 KB
testcase_08 AC 69 ms
24,508 KB
testcase_09 AC 67 ms
24,748 KB
testcase_10 AC 68 ms
24,672 KB
testcase_11 AC 65 ms
24,392 KB
testcase_12 AC 73 ms
24,552 KB
testcase_13 AC 66 ms
24,532 KB
testcase_14 AC 70 ms
25,168 KB
testcase_15 AC 102 ms
24,932 KB
testcase_16 AC 77 ms
24,908 KB
testcase_17 AC 81 ms
24,680 KB
testcase_18 AC 82 ms
24,620 KB
testcase_19 AC 91 ms
24,756 KB
testcase_20 AC 107 ms
25,136 KB
testcase_21 AC 80 ms
24,488 KB
testcase_22 AC 74 ms
24,488 KB
testcase_23 AC 92 ms
24,456 KB
testcase_24 AC 85 ms
25,024 KB
testcase_25 AC 58 ms
24,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
import math

n = int(input())
while True:
  a = random.randint(2, n - 2)
  b = math.gcd(n, a)
  if b != 1:
    print("!", b, n // b, flush=True)
    break
  print("?", a, flush=True)
  r = int(input())
  if r % 2 == 1:
    continue
  x = pow(a, r // 2, n)
  if x == n - 1:
    continue
  p = math.gcd(n, x + 1)
  print("!", p, n // p, flush=True)
  break
    
0