結果

問題 No.8056 量子コンピュータで素因数分解 Easy
ユーザー chocorusk
提出日時 2020-02-05 02:47:52
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 28,000 KB
平均クエリ数 3.12
最終ジャッジ日時 2024-12-31 19:24:05
合計ジャッジ時間 5,260 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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