結果
| 問題 | No.1666 累乗数 |
| コンテスト | |
| ユーザー |
Kiri8128
|
| 提出日時 | 2021-09-03 22:59:22 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,941 ms / 2,000 ms |
| コード長 | 737 bytes |
| 記録 | |
| コンパイル時間 | 246 ms |
| コンパイル使用メモリ | 85,196 KB |
| 実行使用メモリ | 82,612 KB |
| 最終ジャッジ日時 | 2026-05-26 02:01:16 |
| 合計ジャッジ時間 | 19,814 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
def sqrt(n, k = 2):
if n == 0: return 0
l = k - 1
if not n: return 0
y = 1 << (n.bit_length() + l) // k
x = y + 1
while y < x:
x = y
y = (l * x + n // (x ** l)) // k
return x
def cnt(n):
s = 1
for b in range(2, 61):
s += W[b] * (sqrt(n, b) - 1)
return s
W = [0, 0, 1, 1, 0, 1, -1, 1, 0, 0, -1, 1, 0, 1, -1, -1, 0, 1, 0, 1, 0, -1, -1, 1, 0, 0, -1, 0, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, 0, -1, 1, 0, 0, 0, -1, 0, 1, 0, -1, 0, -1, -1, 1, 0]
T = int(input())
for _ in range(T):
K = int(input())
l, r = 0, 10 ** 18
while r - l > 1:
m = l + r >> 1
if cnt(m) < K:
l = m
else:
r = m
print(r)
Kiri8128