結果

問題 No.1271 初めての級数
ユーザー 37zigen
提出日時 2020-11-14 07:26:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 174 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 28,800 KB
最終ジャッジ日時 2025-01-16 00:28:54
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main() {
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%d", &k);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <cstdio>

main() {
    int k;
    scanf("%d", &k);
    double ans=0;
    for (long double i=1;i<1e6;++i) {
        ans+=1/i/(i+k);
    }
    printf("%.12f\n",ans);
}
0