結果

問題 No.1271 初めての級数
ユーザー higopon_higopon_
提出日時 2020-10-30 21:42:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 1,566 ms
コンパイル使用メモリ 166,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 23:52:17
合計ジャッジ時間 2,285 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define PI acos(-1)
typedef  long long ll;
ll MOD=1000000007;

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

int main(){
   int k;
   cin>>k;
   double ans=0;
   for(int i=1;i<=k;i++){
      double tmp=1.0/i;
      ans+=tmp;
   }
   ans/=k;
   if(k==0){
      ans=PI*PI/6.0;
   }
   cout<<setprecision(10)<<ans<<endl;
   
   return 0;
}
0