結果

問題 No.1271 初めての級数
ユーザー 👑 CleyL
提出日時 2022-08-09 19:41:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 89,364 KB
最終ジャッジ日時 2025-01-30 19:46:59
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    int n;cin>>n;
    if(n==0){
        cout << fixed << setprecision(10) << ((double)acos(-1)*acos(-1))/(double)6 << endl;
        return 0;
    }
    double ans = 0;
    for(int i = 1; n >= i; i++){
        ans += (double)1/(double)i;
    }
    cout << fixed << setprecision(10) << (double)ans/(double)n << endl;
}
0