結果
| 問題 |
No.3296 81-like number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 13:48:21 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,073 bytes |
| コンパイル時間 | 4,246 ms |
| コンパイル使用メモリ | 311,820 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-05 13:48:32 |
| 合計ジャッジ時間 | 4,713 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
namespace MyLib
{
template<uint_fast32_t max_value>
[[nodiscard]] static inline constexpr std::array<bool, max_value + 1> make_is_prime() noexcept
{
std::array<bool, max_value + 1> is_prime = { false };
for (uint_fast32_t i = 2; i <= max_value; ++i)
is_prime[i] = true;
for (uint_fast32_t i = 2; i * i <= max_value; ++i)
if (is_prime[i]) [[unlikely]]
for (uint_fast32_t j = i * i; j <= max_value; j += i)
is_prime[j] = false;
return is_prime;
}
}
[[nodiscard]] static inline constexpr uint_fast64_t solve(const uint_fast64_t N) noexcept
{
static constexpr std::array<bool, 100'001> is_prime = MyLib::make_is_prime<100'000>();
uint_fast64_t ans = 0;
for (uint_fast32_t i = 2; static_cast<uint_fast64_t>(i) * i <= N; ++i)
if (is_prime[i])
for (uint_fast64_t term = static_cast<uint_fast64_t>(i) * i; term <= N; term *= i)
ans += term;
return ans;
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast64_t N;
std::cin >> N;
std::cout << solve(N) << '\n';
return 0;
}