結果
問題 |
No.2645 Sum of Divisors?
|
ユーザー |
![]() |
提出日時 | 2024-02-13 23:34:40 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 252 ms / 2,000 ms |
コード長 | 796 bytes |
コンパイル時間 | 2,501 ms |
コンパイル使用メモリ | 244,152 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-28 18:40:54 |
合計ジャッジ時間 | 5,152 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#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; }