結果
| 問題 |
No.2645 Sum of Divisors?
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2024-02-16 20:21:08 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 332 ms / 2,000 ms |
| コード長 | 868 bytes |
| コンパイル時間 | 2,543 ms |
| コンパイル使用メモリ | 245,504 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-09-28 19:36:25 |
| 合計ジャッジ時間 | 5,867 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld euler_number = 0.577215664901532860606512090082;
ld table[100];
void table_build(){
table[0] = 0;
for (int i = 1; i < 100; i++){
table[i] = table[i-1] + ld(1)/ld(i);
}
}
ld harmonic_number(ll n){
if (n < 100) return table[n];
ld ans = logl(n) + euler_number + ld(1)/ld(2*n) - ld(1)/ld(12*n*n);
return ans;
}
int main(){
table_build();
ll n; cin >> n;
ld ansp = 0, ansm = 0;
ll d = 1;
while (true){
ll c = n/d;
if (c == 0) break;
ll le = n/(c+1);
ll ri = n/c;
ansp += harmonic_number(c) * harmonic_number(ri);
ansm += harmonic_number(c) * harmonic_number(le);
d = ri+1;
}
ld ans = ansp - ansm;
cout << fixed << setprecision(20) << ans << endl;
}
noya2