結果

問題 No.2645 Sum of Divisors?
ユーザー umezoumezo
提出日時 2024-02-22 03:25:11
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 916 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 3,343 ms
コンパイル使用メモリ 252,060 KB
実行使用メモリ 105,208 KB
最終ジャッジ日時 2024-02-22 03:25:23
合計ジャッジ時間 11,237 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,256 KB
testcase_01 AC 7 ms
11,384 KB
testcase_02 AC 474 ms
63,992 KB
testcase_03 AC 7 ms
11,256 KB
testcase_04 AC 6 ms
11,256 KB
testcase_05 AC 6 ms
11,256 KB
testcase_06 AC 916 ms
105,208 KB
testcase_07 AC 880 ms
105,208 KB
testcase_08 AC 6 ms
11,256 KB
testcase_09 AC 6 ms
11,256 KB
testcase_10 AC 6 ms
11,256 KB
testcase_11 AC 6 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,384 KB
testcase_15 AC 6 ms
11,384 KB
testcase_16 AC 6 ms
11,384 KB
testcase_17 AC 7 ms
11,384 KB
testcase_18 AC 7 ms
11,640 KB
testcase_19 AC 7 ms
11,640 KB
testcase_20 AC 9 ms
12,152 KB
testcase_21 AC 9 ms
12,024 KB
testcase_22 AC 12 ms
12,536 KB
testcase_23 AC 23 ms
14,200 KB
testcase_24 AC 75 ms
20,600 KB
testcase_25 AC 55 ms
18,168 KB
testcase_26 AC 100 ms
23,416 KB
testcase_27 AC 128 ms
26,616 KB
testcase_28 AC 295 ms
45,304 KB
testcase_29 AC 864 ms
103,032 KB
testcase_30 AC 322 ms
47,736 KB
testcase_31 AC 506 ms
66,040 KB
testcase_32 AC 685 ms
85,624 KB
testcase_33 AC 338 ms
49,656 KB
testcase_34 AC 635 ms
79,992 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=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+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;
}
0