結果

問題 No.2645 Sum of Divisors?
ユーザー noya2noya2
提出日時 2024-02-13 23:34:40
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 2,959 ms
コンパイル使用メモリ 245,212 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-13 23:34:47
合計ジャッジ時間 6,459 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 157 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 280 ms
6,676 KB
testcase_07 AC 277 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 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 3 ms
6,676 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 3 ms
6,676 KB
testcase_22 AC 6 ms
6,676 KB
testcase_23 AC 10 ms
6,676 KB
testcase_24 AC 29 ms
6,676 KB
testcase_25 AC 21 ms
6,676 KB
testcase_26 AC 37 ms
6,676 KB
testcase_27 AC 46 ms
6,676 KB
testcase_28 AC 102 ms
6,676 KB
testcase_29 AC 273 ms
6,676 KB
testcase_30 AC 109 ms
6,676 KB
testcase_31 AC 163 ms
6,676 KB
testcase_32 AC 219 ms
6,676 KB
testcase_33 AC 115 ms
6,676 KB
testcase_34 AC 203 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 ans = 0;
    ll d = 1;
    while (true){
        ll c = n/d;
        if (c == 0) break;
        ll le = n/(c+1);
        ll ri = n/c;
        ans += harmonic_number(c) * (harmonic_number(ri) - harmonic_number(le));
        d = ri+1;
    }
    cout << fixed << setprecision(20) << ans << endl;
}
0