結果

問題 No.1273 はじめのζ関数
ユーザー tnakao0123
提出日時 2020-10-31 01:10:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 95,904 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 04:11:09
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1273.cc:  No.1273 はじめのζ関数 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 20000;
const double PI = acos(-1.0);

const int as[21] = {
  0,
  0, 1000000, 355065, 153009, 70685,
  33758, 16414, 8065, 3988, 1979,
  985, 491, 245, 122, 61,
  30, 15, 7, 3, 1
};

/* typedef */

typedef long long ll;

/* global variables */

double zeta(int n) {
  if (n == 2) return PI * PI / 6;
  double sum = 0.0;
  for (int i = N; i >= 1; i--) sum += pow(1.0 / i, n);
  return sum;
}

void calc() {
  double sum = 0.0;
  for (int i = N; i >= 2; i--) {
    sum += zeta(i) - 1.0;
    int f = floor(sum * 1000000);
    if (f > 0) printf("%d %d\n", i, f);
  }
}

/* subroutines */

/* main */

int main() {
  //calc(); return 0;
  
  int x;
  scanf("%d", &x);

  printf("%d\n", (x <= 20) ? as[x] : 0);
  return 0;
}
0