結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー chocoruskchocorusk
提出日時 2020-02-05 02:49:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 25,212 KB
平均クエリ数 2.69
最終ジャッジ日時 2023-08-30 06:44:22
合計ジャッジ時間 3,974 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
24,356 KB
testcase_01 AC 61 ms
24,604 KB
testcase_02 AC 119 ms
24,560 KB
testcase_03 AC 121 ms
24,696 KB
testcase_04 AC 63 ms
24,884 KB
testcase_05 AC 64 ms
24,884 KB
testcase_06 AC 67 ms
24,704 KB
testcase_07 AC 63 ms
24,452 KB
testcase_08 AC 77 ms
24,696 KB
testcase_09 AC 66 ms
24,396 KB
testcase_10 AC 67 ms
24,664 KB
testcase_11 AC 68 ms
25,212 KB
testcase_12 AC 73 ms
25,040 KB
testcase_13 AC 68 ms
24,792 KB
testcase_14 AC 72 ms
24,488 KB
testcase_15 AC 125 ms
24,328 KB
testcase_16 AC 75 ms
25,016 KB
testcase_17 AC 81 ms
25,004 KB
testcase_18 AC 81 ms
24,524 KB
testcase_19 AC 90 ms
24,508 KB
testcase_20 AC 107 ms
24,656 KB
testcase_21 AC 79 ms
24,548 KB
testcase_22 AC 75 ms
24,472 KB
testcase_23 AC 92 ms
24,976 KB
testcase_24 AC 84 ms
24,544 KB
testcase_25 AC 58 ms
24,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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