結果
| 問題 |
No.1022 Power Equation
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-10 21:37:14 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 531 ms / 2,000 ms |
| コード長 | 865 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 44,228 KB |
| 最終ジャッジ日時 | 2024-09-15 19:31:35 |
| 合計ジャッジ時間 | 6,012 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
import itertools
T = int(readline())
nums = np.array(read().split(), np.int64)
count = np.zeros_like(nums)
# a = c = 1
count += nums ** 2
def find_kth_root_int(a, k):
if k == 0:
return 0
x = int(a ** (1 / k))
while (x ** k > a):
x -= 1
while ((x + 1) ** k <= a):
x += 1
return x
bounds = []
for k in range(40):
# r^k <= N となる r の最大値を求める
R = np.array([find_kth_root_int(x, k) for x in nums], np.int64)
bounds.append(R)
for k, l in itertools.product(range(1, 40), repeat=2):
if np.gcd(k, l) > 1:
continue
cnt_r = bounds[max(k, l)] - 1
cnt_bd = nums // max(k, l)
count += cnt_r * cnt_bd
print('\n'.join(count.astype(str)))
maspy