結果
問題 | No.2645 Sum of Divisors? |
ユーザー |
![]() |
提出日時 | 2024-02-22 03:09:41 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 796 ms / 2,000 ms |
コード長 | 754 bytes |
コンパイル時間 | 2,968 ms |
コンパイル使用メモリ | 253,120 KB |
実行使用メモリ | 105,096 KB |
最終ジャッジ日時 | 2024-09-29 04:24:03 |
合計ジャッジ時間 | 9,019 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}