結果

問題 No.1273 はじめのζ関数
ユーザー platinum
提出日時 2020-09-21 17:28:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 69,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 22:52:48
合計ジャッジ時間 1,736 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <assert.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
const LL INF = 1e12;

const int Max_x = 1e4;
const int Max_a = 1e6;

double zeta(LL a, LL x){
  LL res = a - 1;
  rep(i,x - 1){
    res *= a;
    if(res > INF) break;
  }
  double d = res;
  return 1 / d;
}

int main(){
  LL x;
  cin >> x;
  assert(2 <= x and x <= Max_x);
  double ans = 0.0;
  if(x == 2) cout << 2 << endl;
  else{
    for(LL a = 2; a <= Max_a; a++) ans += zeta(a, x);
    cout << setprecision(15) << ans << endl;
  }

  return 0;
}
0