結果

問題 No.2645 Sum of Divisors?
ユーザー noya2noya2
提出日時 2024-02-16 20:21:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 3,038 ms
コンパイル使用メモリ 245,348 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-16 20:21:17
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 181 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 333 ms
6,676 KB
testcase_07 AC 331 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 3 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 11 ms
6,676 KB
testcase_24 AC 33 ms
6,676 KB
testcase_25 AC 25 ms
6,676 KB
testcase_26 AC 43 ms
6,676 KB
testcase_27 AC 53 ms
6,676 KB
testcase_28 AC 117 ms
6,676 KB
testcase_29 AC 315 ms
6,676 KB
testcase_30 AC 127 ms
6,676 KB
testcase_31 AC 189 ms
6,676 KB
testcase_32 AC 276 ms
6,676 KB
testcase_33 AC 132 ms
6,676 KB
testcase_34 AC 236 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld euler_number = 0.577215664901532860606512090082;

ld table[100];

void table_build(){
    table[0] = 0;
    for (int i = 1; i < 100; i++){
        table[i] = table[i-1] + ld(1)/ld(i);
    }
}

ld harmonic_number(ll n){
    if (n < 100) return table[n];
    ld ans = logl(n) + euler_number + ld(1)/ld(2*n) - ld(1)/ld(12*n*n);
    return ans;
}

int main(){
    table_build();
    ll n; cin >> n;
    ld ansp = 0, ansm = 0;
    ll d = 1;
    while (true){
        ll c = n/d;
        if (c == 0) break;
        ll le = n/(c+1);
        ll ri = n/c;
        ansp += harmonic_number(c) * harmonic_number(ri);
        ansm += harmonic_number(c) * harmonic_number(le);
        d = ri+1;
    }
    ld ans = ansp - ansm;
    cout << fixed << setprecision(20) << ans << endl;
}
0