結果

問題 No.1271 初めての級数
ユーザー ktr216ktr216
提出日時 2020-10-30 21:48:59
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 1,297 ms
使用メモリ 9,700 KB
最終ジャッジ日時 2023-02-21 12:05:50
合計ジャッジ時間 2,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 303 ms
7,576 KB
testcase_01 AC 2 ms
7,588 KB
testcase_02 AC 2 ms
9,692 KB
testcase_03 AC 2 ms
9,668 KB
testcase_04 AC 1 ms
7,608 KB
testcase_05 AC 2 ms
9,688 KB
testcase_06 AC 2 ms
9,672 KB
testcase_07 AC 1 ms
7,652 KB
testcase_08 AC 1 ms
7,612 KB
testcase_09 AC 1 ms
9,696 KB
testcase_10 AC 1 ms
9,700 KB
testcase_11 AC 2 ms
7,604 KB
testcase_12 AC 1 ms
7,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long ll;

int main() {
    ll k;
    cin >> k;
    if (k == 0) {
        double ans = 0;
        rep(i, 100000000) {
            ans += 1.0 / (i + 1) / (i + 1);
        }
        cout << fixed << setprecision(16) << ans << "\n";
        return 0;
    }
    double ans = 0;
    rep(i, k) {
        ans += 1.0 / (i + 1);
    }
    ans /= k;
    cout << fixed << setprecision(16) << ans << "\n";
}
0