結果

問題 No.1273 はじめのζ関数
コンテスト
ユーザー ygussany
提出日時 2020-10-31 12:14:12
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 703 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 327 ms
コンパイル使用メモリ 41,924 KB
最終ジャッジ日時 2026-02-22 06:16:45
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <math.h>

int main()
{
	int i, j, x;
	long double ans = 0.0, tmp;
	scanf("%d", &x);
	if (x == 2) printf("1000000\n");
	else if (x >= 5) {
		for (i = 50; i >= x; i--) {
			for (j = 200, tmp = 0.0; j >= 1; j--) tmp += powl(j, -i);
			ans += tmp - 1.0;
		}
		printf("%d\n", (int)(ans * 1000000));
	} else {
		for (i = 50; i >= 5; i--) {
			for (j = 200, tmp = 0.0; j >= 1; j--) tmp += powl(j, -i);
			ans += tmp - 1.0;
		}
		for (j = 500, tmp = 0.0; j >= 1; j--) tmp += powl(j, -4);
		ans += tmp - 1.0;
		if (x <= 3) {
			for (j = 1000, tmp = 0.0; j >= 1; j--) tmp += powl(j, -3);
			ans += tmp - 1.0;
		}
		printf("%d\n", (int)(ans * 1000000));
	}
	fflush(stdout);
	return 0;
}
0