結果

問題 No.2645 Sum of Divisors?
ユーザー shobonvip
提出日時 2024-02-11 11:09:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 532 bytes
コンパイル時間 2,467 ms
コンパイル使用メモリ 191,564 KB
最終ジャッジ日時 2025-02-19 04:56:28
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const double mathgamma = 0.5772156649015328606065120;
const long long mx = 1000000;

double H_table[mx + 1];

double H(long long n){
	if (n < 0) return 0;
	if (n <= mx) return H_table[n];
	return log(n) + mathgamma + (double)1 / (n * 2);
}

int main(){
	for (int i=1; i<=mx; i++){
		H_table[i] = H_table[i-1] + (double)1 / i;
	}

	long long n;
	cin >> n;
	double ans = 0;
	
	for (int i=1; i<=n; i++){
		ans += H(n / i) / i;
	}

	cout << fixed << setprecision(15);
	cout << ans << '\n';
}
0