結果

問題 No.2645 Sum of Divisors?
ユーザー てんぷらてんぷら
提出日時 2024-02-19 22:42:09
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,156 bytes
コンパイル時間 5,068 ms
コンパイル使用メモリ 308,744 KB
実行使用メモリ 19,196 KB
最終ジャッジ日時 2024-02-19 22:42:17
合計ジャッジ時間 7,181 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
19,196 KB
testcase_01 AC 10 ms
19,196 KB
testcase_02 AC 57 ms
19,196 KB
testcase_03 AC 10 ms
19,196 KB
testcase_04 AC 10 ms
19,196 KB
testcase_05 AC 10 ms
19,196 KB
testcase_06 AC 134 ms
19,196 KB
testcase_07 AC 134 ms
19,196 KB
testcase_08 AC 11 ms
19,196 KB
testcase_09 AC 10 ms
19,196 KB
testcase_10 AC 10 ms
19,196 KB
testcase_11 AC 10 ms
19,196 KB
testcase_12 AC 9 ms
19,196 KB
testcase_13 AC 10 ms
19,196 KB
testcase_14 AC 9 ms
19,196 KB
testcase_15 AC 10 ms
19,196 KB
testcase_16 AC 9 ms
19,196 KB
testcase_17 AC 8 ms
19,196 KB
testcase_18 AC 10 ms
19,196 KB
testcase_19 AC 10 ms
19,196 KB
testcase_20 AC 10 ms
19,196 KB
testcase_21 AC 9 ms
19,196 KB
testcase_22 AC 10 ms
19,196 KB
testcase_23 AC 11 ms
19,196 KB
testcase_24 AC 14 ms
19,196 KB
testcase_25 AC 12 ms
19,196 KB
testcase_26 AC 15 ms
19,196 KB
testcase_27 AC 17 ms
19,196 KB
testcase_28 AC 31 ms
19,196 KB
testcase_29 AC 124 ms
19,196 KB
testcase_30 AC 34 ms
19,196 KB
testcase_31 AC 57 ms
19,196 KB
testcase_32 AC 89 ms
19,196 KB
testcase_33 AC 37 ms
19,196 KB
testcase_34 AC 81 ms
19,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const int inf = 1000000007;
const ll longinf = 1ll << 60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vector<long double> sum(1000001);
    REP(i, 1, 1000001) {
        sum[i] = sum[i - 1] + 1.0 / i;
    }
    auto calc = [&](ll x) {
        if(x <= 1000000)
            return sum[x];
        else
            return log((long double)x) + 0.5772156649015;
    };
    long double ans = 0;
    REP(i, 1, 1000001) {
        if(i > n / i) {
            break;
        }
        ans += calc(i) * (calc(n / i) - calc(n / (i + 1)));
        // cout << i << " " << cnt << endl;
    }
    REP(i, 1, 1000001) {
        if(i >= n / i) {
            break;
        }
        ans += calc(n / i) / i;
        // cout << i << " " << endl;
    }
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}
0