結果

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

ソースコード

diff #

#include <iostream>
#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 res = 0.0;
  if(x == 2){
    cout << 1000000 << endl;
  }
  else{
    for(LL a = 2; a <= Max_a; a++) res += zeta(a, x);
    res *= 1000000;
    int ans = res;
    cout << ans << endl;
  }

  return 0;
}
0