結果

問題 No.1273 はじめのζ関数
ユーザー Mister
提出日時 2020-10-30 21:50:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 624 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 91,220 KB
最終ジャッジ日時 2025-01-15 17:08:23
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample TLE * 1
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using ldouble = long double;
constexpr ldouble INF = 1e20;

void solve() {
    int x;
    std::cin >> x;

    if (x == 2) {
        std::cout << 1000000 << "\n";
        return;
    }

    ldouble ans = 0;
    for (ldouble i = 2;; ++i) {
        if (std::pow(i, x) > INF) break;

        for (int p = x; std::pow(i, p) <= INF; ++p) {
            ans += std::pow(i, -p);
        }
    }

    std::cout << std::floor(ans * 1e6) << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0