結果

問題 No.2645 Sum of Divisors?
ユーザー RubikunRubikun
提出日時 2024-02-19 22:44:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,762 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 203,056 KB
実行使用メモリ 160,244 KB
最終ジャッジ日時 2024-02-19 22:44:09
合計ジャッジ時間 6,303 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) >= b

ll floorless(ll a,ll b){
    return (a+b+1)/(b+1);
}
// min x , s.t. floor(a/x) <= b

ll ceilmore(ll a,ll b){
    if(b==1) return a+1;
    return (a-1)/(b-1);
}
// max x , s.t. ceil(a/x) >= b

ll ceilless(ll a,ll b){
    return (a+b-1)/b;
}
// min x , s.t. ceil(a/x) <= b

double 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;
    }
}

0