結果

問題 No.2645 Sum of Divisors?
ユーザー umezoumezo
提出日時 2024-02-26 07:21:25
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 692 bytes
コンパイル時間 3,391 ms
コンパイル使用メモリ 245,972 KB
実行使用メモリ 11,384 KB
最終ジャッジ日時 2024-02-26 07:21:31
合計ジャッジ時間 5,400 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,256 KB
testcase_01 AC 6 ms
11,256 KB
testcase_02 AC 53 ms
11,384 KB
testcase_03 AC 6 ms
11,256 KB
testcase_04 AC 6 ms
11,256 KB
testcase_05 AC 6 ms
11,256 KB
testcase_06 AC 101 ms
11,384 KB
testcase_07 AC 100 ms
11,384 KB
testcase_08 AC 6 ms
11,256 KB
testcase_09 AC 7 ms
11,256 KB
testcase_10 AC 7 ms
11,256 KB
testcase_11 AC 7 ms
11,256 KB
testcase_12 AC 6 ms
11,256 KB
testcase_13 AC 7 ms
11,256 KB
testcase_14 AC 7 ms
11,256 KB
testcase_15 AC 6 ms
11,256 KB
testcase_16 AC 6 ms
11,256 KB
testcase_17 AC 6 ms
11,256 KB
testcase_18 AC 7 ms
11,384 KB
testcase_19 AC 7 ms
11,384 KB
testcase_20 AC 7 ms
11,384 KB
testcase_21 AC 7 ms
11,384 KB
testcase_22 AC 8 ms
11,384 KB
testcase_23 AC 9 ms
11,384 KB
testcase_24 AC 15 ms
11,384 KB
testcase_25 AC 13 ms
11,384 KB
testcase_26 AC 17 ms
11,384 KB
testcase_27 AC 19 ms
11,384 KB
testcase_28 AC 35 ms
11,384 KB
testcase_29 AC 97 ms
11,384 KB
testcase_30 AC 38 ms
11,384 KB
testcase_31 AC 55 ms
11,384 KB
testcase_32 AC 77 ms
11,384 KB
testcase_33 AC 39 ms
11,384 KB
testcase_34 AC 71 ms
11,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0