結果

問題 No.2645 Sum of Divisors?
ユーザー ripityripity
提出日時 2024-02-21 15:39:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 203,436 KB
実行使用メモリ 81,800 KB
最終ジャッジ日時 2024-02-21 15:39:34
合計ジャッジ時間 5,543 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
81,672 KB
testcase_01 AC 39 ms
81,672 KB
testcase_02 AC 66 ms
81,800 KB
testcase_03 AC 39 ms
81,672 KB
testcase_04 AC 39 ms
81,672 KB
testcase_05 AC 39 ms
81,672 KB
testcase_06 AC 85 ms
81,800 KB
testcase_07 AC 85 ms
81,800 KB
testcase_08 AC 40 ms
81,672 KB
testcase_09 AC 39 ms
81,672 KB
testcase_10 AC 39 ms
81,672 KB
testcase_11 AC 41 ms
81,672 KB
testcase_12 AC 39 ms
81,672 KB
testcase_13 AC 39 ms
81,672 KB
testcase_14 AC 39 ms
81,672 KB
testcase_15 AC 39 ms
81,672 KB
testcase_16 AC 39 ms
81,672 KB
testcase_17 AC 39 ms
81,672 KB
testcase_18 AC 39 ms
81,672 KB
testcase_19 AC 39 ms
81,672 KB
testcase_20 AC 42 ms
81,800 KB
testcase_21 AC 39 ms
81,800 KB
testcase_22 AC 39 ms
81,800 KB
testcase_23 AC 41 ms
81,800 KB
testcase_24 AC 43 ms
81,800 KB
testcase_25 AC 43 ms
81,800 KB
testcase_26 AC 46 ms
81,800 KB
testcase_27 AC 48 ms
81,800 KB
testcase_28 AC 57 ms
81,800 KB
testcase_29 AC 83 ms
81,800 KB
testcase_30 AC 58 ms
81,800 KB
testcase_31 AC 66 ms
81,800 KB
testcase_32 AC 77 ms
81,800 KB
testcase_33 AC 59 ms
81,800 KB
testcase_34 AC 73 ms
81,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

double H_approximate(long long n) {
    return log(n)+0.5772156649015328606065121;
}

int main() {
    constexpr int H_SIZE = 1e7;
    vector<double> H(H_SIZE+1);
    for( long long n = 1; n <= H_SIZE; n++ ) {
        H[n] = H[n-1]+pow(n, -1.0);
    }
    auto h = [&](long long n) -> double {
        return n <= H_SIZE ? H[n] : H_approximate(n);
    };
    long long N;
    cin >> N;
    double ans = 0;
    long long sqrtn = floor(sqrt(N));
    for( long long n = 1; n <= sqrtn; n++ ) {
        ans += pow(n, -1.0)*h(N/n);
    }
    for( long long k = 1; k <= N/(sqrtn+1); k++ ) {
        ans += (h(N/k)-h(N/(k+1)))*h(k);
    }
    cout << fixed << setprecision(10) << ans << endl;
}
0