結果
問題 | No.2645 Sum of Divisors? |
ユーザー |
![]() |
提出日時 | 2024-02-19 22:44:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,762 bytes |
コンパイル時間 | 2,064 ms |
コンパイル使用メモリ | 195,004 KB |
最終ジャッジ日時 | 2025-02-19 17:24:46 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 32 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }#define all(x) (x).begin(),(x).end()#define fi first#define se second#define mp make_pair#define si(x) int(x.size())const int mod=998244353,MAX=20000005,INF=1<<30;double rui[MAX];const double eu=0.577215664901532860606512090082;ll floormore(ll a,ll b){return a/b;}// max x , s.t. floor(a/x) >= bll floorless(ll a,ll b){return (a+b+1)/(b+1);}// min x , s.t. floor(a/x) <= bll ceilmore(ll a,ll b){if(b==1) return a+1;return (a-1)/(b-1);}// max x , s.t. ceil(a/x) >= bll ceilless(ll a,ll b){return (a+b-1)/b;}// min x , s.t. ceil(a/x) <= bdouble f(ll x){if(x<MAX) return rui[x];else return log(x+1)+(double)(x)/2/(x+1)+eu-1.0/2;}int main(){std::ifstream in("text.txt");std::cin.rdbuf(in.rdbuf());cin.tie(0);ios::sync_with_stdio(false);for(int i=1;i<MAX;i++){rui[i]=rui[i-1]+1.0/i;}cout<<fixed<<setprecision(25);cout<<rui[20000000]<<endl;cout<<rui[20000001]<<endl;ll N;cin>>N;if(N<=1000000){double ans=0;for(ll x=1;x<=1000000;x++){ans+=f(N/x)/x;}cout<<ans<<endl;}else{double ans=0;for(ll x=1;x<=1000000;x++){ans+=f(N/x)/x;}for(ll x=1;x<=1000000;x++){ll l=floorless(N,x),r=floormore(N,x);chmax(l,1000001LL);if(l<=r){ans+=(f(r)-f(l-1))*rui[x];}}cout<<ans<<endl;}}