結果

問題 No.1271 初めての級数
ユーザー kpinkcatkpinkcat
提出日時 2023-08-29 17:22:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 102,584 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-29 17:23:06
合計ジャッジ時間 6,354 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:18:14: 警告: ‘sum1’ is used uninitialized [-Wuninitialized]
   18 |         sum1 += (1./i/(i+k));
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:16:12: 備考: ‘sum1’ はここで定義されています
   16 |     double sum1;
      |            ^~~~

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using namespace std;

int main()
{
    int k;
    cin >> k;
    double sum1;
    for (int i = 1; i < 1e8; i++){
        sum1 += (1./i/(i+k));
    }
    cout << fixed << setprecision(8);
    cout << sum1 << endl;
}   

0