結果

問題 No.3056 量子コンピュータで素因数分解 Easy
ユーザー chocoruskchocorusk
提出日時 2020-02-05 03:00:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 402 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 24,924 KB
平均クエリ数 2.35
最終ジャッジ日時 2023-08-30 06:45:39
合計ジャッジ時間 4,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
24,896 KB
testcase_01 AC 70 ms
24,780 KB
testcase_02 AC 129 ms
24,552 KB
testcase_03 AC 130 ms
24,648 KB
testcase_04 AC 77 ms
24,388 KB
testcase_05 AC 81 ms
24,776 KB
testcase_06 AC 74 ms
24,568 KB
testcase_07 AC 75 ms
24,624 KB
testcase_08 AC 68 ms
24,640 KB
testcase_09 AC 64 ms
24,600 KB
testcase_10 AC 66 ms
24,360 KB
testcase_11 AC 64 ms
24,444 KB
testcase_12 AC 72 ms
24,432 KB
testcase_13 AC 64 ms
24,924 KB
testcase_14 AC 69 ms
24,268 KB
testcase_15 AC 79 ms
24,552 KB
testcase_16 AC 74 ms
24,444 KB
testcase_17 AC 77 ms
24,500 KB
testcase_18 AC 79 ms
24,612 KB
testcase_19 AC 90 ms
24,588 KB
testcase_20 AC 105 ms
24,648 KB
testcase_21 AC 79 ms
24,648 KB
testcase_22 AC 73 ms
24,636 KB
testcase_23 AC 98 ms
24,880 KB
testcase_24 AC 84 ms
24,680 KB
testcase_25 AC 58 ms
24,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from random import randint
from math import gcd
n=int(input())
while True:
  a=randint(2, n-1)
  g=gcd(a, n)
  if g!=1:
    print("! %d %d" % (g, n//g))
    sys.stdout.flush()
    break
  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=gcd(x+1, n)
  print("! %d %d" % (p, n//p))
  sys.stdout.flush()
  break
0