結果

問題 No.881 sin(x)/xの和
ユーザー 37zigen37zigen
提出日時 2019-09-07 20:32:34
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,198 bytes
コンパイル時間 2,421 ms
コンパイル使用メモリ 74,524 KB
実行使用メモリ 63,332 KB
最終ジャッジ日時 2023-08-13 13:03:46
合計ジャッジ時間 12,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 472 ms
61,856 KB
testcase_01 WA -
testcase_02 AC 350 ms
61,872 KB
testcase_03 AC 370 ms
62,220 KB
testcase_04 AC 498 ms
63,120 KB
testcase_05 AC 296 ms
60,412 KB
testcase_06 AC 265 ms
58,232 KB
testcase_07 AC 304 ms
60,380 KB
testcase_08 AC 458 ms
62,496 KB
testcase_09 AC 383 ms
61,868 KB
testcase_10 AC 366 ms
62,336 KB
testcase_11 AC 409 ms
62,464 KB
testcase_12 AC 446 ms
62,300 KB
testcase_13 AC 363 ms
61,244 KB
testcase_14 AC 325 ms
60,644 KB
testcase_15 AC 322 ms
61,148 KB
testcase_16 AC 395 ms
61,844 KB
testcase_17 AC 311 ms
60,440 KB
testcase_18 AC 352 ms
61,756 KB
testcase_19 AC 387 ms
63,332 KB
testcase_20 AC 257 ms
58,476 KB
testcase_21 AC 414 ms
62,068 KB
testcase_22 AC 447 ms
62,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	double sinc(double x) {
		if (x < 1e-8) {
			return 1;
		} else {
			return Math.sin(x) / x;
		}
	}

	double solve(double x, double a) {
		double ret = Math.cos(x + 0.5) / (x + 1) + Math.cos(-x + 0.5) / (-x + 1);
		double cx = Math.cos(x);
		double sx = Math.sin(x);
		for (int i = 1; i < 10000; ++i) {
			ret -= (cx * cos[i] - sx * sin[i]) / (x + i + 1) / (x + i);
			ret -= (cx * cos[i] + sx * sin[i]) / (-x + i + 1) / (-x + i);
		}
		ret *= 0.5 / Math.sin(0.5);
		ret += sinc(x);
		return a * ret;
	}

	double[] cos = new double[10000];
	double[] sin = new double[10000];
	{
		for (int i = 0; i < cos.length; ++i) {
			cos[i] = Math.cos(i + 0.5);
			sin[i] = Math.sin(i + 0.5);
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double ans = 0;
		for (int i = 0; i < n; ++i) {
			double x = sc.nextDouble();
			double a = sc.nextDouble();
			ans += solve(x, a);
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0