結果
問題 | No.2645 Sum of Divisors? |
ユーザー |
![]() |
提出日時 | 2024-02-25 05:38:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 620 bytes |
コンパイル時間 | 768 ms |
コンパイル使用メモリ | 78,172 KB |
最終ジャッジ日時 | 2025-02-19 21:15:05 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <cmath> using namespace std; typedef long long ll; typedef long double ld; ld h[1000010]; const ld eu = 0.5772156649; ld H(ll n){ if(n<=1000000) return h[n]; return log(n) + eu + (ld)1/(ld)2/(ld)n - (ld)1/(ld)12/(ld)n/(ld)n + (ld)1/(ld)120/(ld)n/(ld)n/(ld)n/(ld)n; } int main(){ cout.precision(20); for(int i=1;i<=1000000;i++){ h[i] = h[i - 1] + (ld)1/(ld)i; } ll n; cin >> n; ld ans = 0; for(ll l = 1;l<=n;){ ll r = n/(n/l); if(l>r) break; ans += (H(r) - H(l - 1))*H(n/l); l = r + 1; } cout << ans << "\n"; }