結果

問題 No.1273 はじめのζ関数
ユーザー 👑 ygussany
提出日時 2020-10-31 12:12:37
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 1,054 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 04:53:51
合計ジャッジ時間 1,312 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#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("0\n");
	else if (x >= 5) {
		for (i = 50; i >= x; i--) {
			for (j = 100, 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 = 100, tmp = 0.0; j >= 1; j--) tmp += powl(j, -i);
			ans += tmp - 1.0;
		}
		for (j = 100, 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