結果

問題 No.1271 初めての級数
ユーザー kyo1
提出日時 2020-11-08 01:03:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 969 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 192,156 KB
最終ジャッジ日時 2025-01-15 21:35:49
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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