結果

問題 No.2645 Sum of Divisors?
ユーザー shobonvipshobonvip
提出日時 2024-02-11 11:09:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 532 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 201,524 KB
実行使用メモリ 18,160 KB
最終ジャッジ日時 2024-02-12 13:29:29
合計ジャッジ時間 5,468 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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