結果

問題 No.1271 初めての級数
ユーザー kyo1kyo1
提出日時 2020-11-08 01:03:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 952 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 1,698 ms
コンパイル使用メモリ 197,496 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 21:04:20
合計ジャッジ時間 8,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
4,376 KB
testcase_01 AC 237 ms
4,380 KB
testcase_02 AC 231 ms
4,376 KB
testcase_03 AC 933 ms
4,380 KB
testcase_04 AC 952 ms
4,380 KB
testcase_05 AC 237 ms
4,376 KB
testcase_06 AC 236 ms
4,380 KB
testcase_07 AC 680 ms
4,380 KB
testcase_08 AC 671 ms
4,376 KB
testcase_09 AC 673 ms
4,380 KB
testcase_10 AC 347 ms
4,380 KB
testcase_11 AC 673 ms
4,380 KB
testcase_12 AC 335 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K;
  cin >> K;
  double res = 0;
  for (double i = 1;; i++) {
    auto prev = res;
    res += static_cast<double>(1) / (i * (i + K));
    if (prev == res) break;
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}
0