結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
24,704 KB
testcase_01 AC 70 ms
24,520 KB
testcase_02 AC 110 ms
24,788 KB
testcase_03 AC 111 ms
24,728 KB
testcase_04 AC 61 ms
25,228 KB
testcase_05 AC 62 ms
24,940 KB
testcase_06 AC 64 ms
24,508 KB
testcase_07 AC 61 ms
24,856 KB
testcase_08 AC 64 ms
24,528 KB
testcase_09 AC 66 ms
25,016 KB
testcase_10 AC 66 ms
24,472 KB
testcase_11 AC 84 ms
24,700 KB
testcase_12 AC 106 ms
24,588 KB
testcase_13 AC 66 ms
25,232 KB
testcase_14 AC 163 ms
24,416 KB
testcase_15 AC 171 ms
24,492 KB
testcase_16 AC 74 ms
25,000 KB
testcase_17 AC 76 ms
25,120 KB
testcase_18 AC 78 ms
24,604 KB
testcase_19 AC 166 ms
24,504 KB
testcase_20 AC 99 ms
24,724 KB
testcase_21 AC 76 ms
24,512 KB
testcase_22 AC 86 ms
24,420 KB
testcase_23 AC 87 ms
24,432 KB
testcase_24 AC 81 ms
25,176 KB
testcase_25 AC 58 ms
24,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import random
import math
n=int(input())
a=1
while True:
  a+=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