結果

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#define ll long long

const long double PI = acosl(-1.0);

using namespace std;

int main(){
    cout << fixed << setprecision(15);
    int n;
    cin >> n;
    if(n == 0){
        cout << PI*PI/6 << endl;
        return 0;
    }
    long double sum = 0;
    for(int i = 1;i <= n;i++){
        long double x = 1/(long double)i;
        sum += x;
    }
    sum /= (long double)n;
    cout << sum << endl;
    return 0;
}
0