結果
問題 | No.3056 量子コンピュータで素因数分解 Easy |
ユーザー | trineutron |
提出日時 | 2020-11-25 19:33:00 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 595 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 10,772 KB |
実行使用メモリ | 25,168 KB |
平均クエリ数 | 2.12 |
最終ジャッジ日時 | 2023-08-30 06:57:26 |
合計ジャッジ時間 | 3,789 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
24,652 KB |
testcase_01 | AC | 61 ms
25,168 KB |
testcase_02 | AC | 117 ms
24,420 KB |
testcase_03 | AC | 118 ms
24,592 KB |
testcase_04 | AC | 62 ms
25,072 KB |
testcase_05 | AC | 69 ms
25,140 KB |
testcase_06 | AC | 65 ms
25,048 KB |
testcase_07 | AC | 61 ms
24,684 KB |
testcase_08 | WA | - |
testcase_09 | AC | 66 ms
24,720 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 67 ms
24,676 KB |
testcase_14 | WA | - |
testcase_15 | AC | 82 ms
25,028 KB |
testcase_16 | AC | 77 ms
24,932 KB |
testcase_17 | AC | 81 ms
24,752 KB |
testcase_18 | AC | 82 ms
24,844 KB |
testcase_19 | WA | - |
testcase_20 | AC | 104 ms
24,328 KB |
testcase_21 | AC | 80 ms
24,460 KB |
testcase_22 | WA | - |
testcase_23 | AC | 89 ms
25,132 KB |
testcase_24 | AC | 83 ms
24,684 KB |
testcase_25 | AC | 57 ms
24,776 KB |
ソースコード
import math import sys import random n = int(input()) while True: i = random.randrange(2, n) if math.gcd(n, i) != 1: continue if n % i == 0: print('! %d %d' % (i, n // i)) exit() print('? %d' % i) sys.stdout.flush() t = int(input()) if t % 2 == 0: x = pow(i, t // 2, n) x0 = math.gcd(x + 1, n) x1 = math.gcd(x - 1, n) if x0 >= 2 and n % x0 == 0: print('! %d %d' % (x0, n // x0)) exit() if x1 >= 2 and n % x1 == 0: print('! %d %d' % (x1, n // x1)) exit()