結果
問題 |
No.2645 Sum of Divisors?
|
ユーザー |
![]() |
提出日時 | 2024-02-22 03:09:08 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 907 ms / 2,000 ms |
コード長 | 754 bytes |
コンパイル時間 | 7,797 ms |
コンパイル使用メモリ | 260,356 KB |
最終ジャッジ日時 | 2025-02-19 18:42:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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=std::numbers::egamma; 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; for(int i=2;i<=k;i++) H[i]+=H[i-1]; ll n; cin>>n; set<ll> s; for(ll i=1;i*i<=n;i++){ s.insert(i); s.insert(n/i); } auto f=[&](ll d){ if(d<=k) return H[d]; return harmonic(d); }; double ans=0; for(auto d:s) ans+=f(d)*(f(n/d)-f(n/(d+1))); printf("%.20f\n",ans); return 0; }