結果
問題 |
No.2645 Sum of Divisors?
|
ユーザー |
![]() |
提出日時 | 2024-02-26 07:21:25 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 2,761 ms |
コンパイル使用メモリ | 245,492 KB |
実行使用メモリ | 11,608 KB |
最終ジャッジ日時 | 2024-09-29 11:34:41 |
合計ジャッジ時間 | 4,361 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; const double c=0.577215664901532; double harmonic(ll k){ double t=k; double ret=log(t)+c+0.5/t-1.0/12/t/t; return ret; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int k=1000000; vector<double> H(k+1); for(int i=1;i<=k;i++) H[i]=1.0/i+H[i-1]; ll n; cin>>n; auto f=[&](ll d){ if(d<=k) return H[d]; return harmonic(d); }; double ans=0; ll r,l,q; r=n; while(r){ q=n/r; l=n/(q+1); ans+=f(q)*(f(n/q)-f(n/(q+1))); r=l; } printf("%.20f\n",ans); return 0; }