結果
問題 | No.1063 ルートの計算 / Sqrt Calculation |
ユーザー |
|
提出日時 | 2020-05-29 21:34:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,058 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 817,888 KB |
最終ジャッジ日時 | 2024-11-06 02:40:53 |
合計ジャッジ時間 | 3,533 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 RE * 3 MLE * 1 -- * 8 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter class Prime_Decomposition: def __init__(self, n_max): self.min_factor = min_factor = list(range(n_max + 1)) for i in range(2, int(n_max ** 0.5) + 1): if min_factor[i] == i: for j in range(i * i, n_max + 1, i): if min_factor[j] == j: min_factor[j] = i def __call__(self, n): min_factor = self.min_factor n_twoes = (n & -n).bit_length() - 1 # 最悪ケースでは速くなる res = [2] * n_twoes n >>= n_twoes while n > 1: p = min_factor[n] res.append(p) n //= p return res n = int(readline()) prime_check = Prime_Decomposition(n + 1) a = 1 b = 1 for k, v in Counter(prime_check(n)).items(): x, y = divmod(v, 2) if x != 0: a *= k ** x if y != 0: b *= k print(a, b)