結果

問題 No.881 sin(x)/xの和
ユーザー 37zigen37zigen
提出日時 2019-09-07 20:28:23
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 949 bytes
コンパイル時間 2,275 ms
コンパイル使用メモリ 80,400 KB
実行使用メモリ 66,108 KB
最終ジャッジ日時 2023-08-13 13:04:11
合計ジャッジ時間 20,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,189 ms
65,900 KB
testcase_01 WA -
testcase_02 AC 591 ms
61,648 KB
testcase_03 AC 638 ms
62,044 KB
testcase_04 AC 1,332 ms
65,876 KB
testcase_05 AC 418 ms
61,740 KB
testcase_06 AC 303 ms
58,012 KB
testcase_07 AC 464 ms
62,540 KB
testcase_08 AC 1,130 ms
66,108 KB
testcase_09 AC 674 ms
62,356 KB
testcase_10 AC 672 ms
62,412 KB
testcase_11 AC 932 ms
63,348 KB
testcase_12 AC 1,092 ms
64,272 KB
testcase_13 AC 640 ms
62,208 KB
testcase_14 AC 511 ms
62,020 KB
testcase_15 AC 514 ms
62,464 KB
testcase_16 AC 759 ms
62,408 KB
testcase_17 AC 481 ms
62,824 KB
testcase_18 AC 596 ms
61,600 KB
testcase_19 AC 732 ms
62,716 KB
testcase_20 AC 274 ms
58,016 KB
testcase_21 AC 684 ms
62,516 KB
testcase_22 AC 1,005 ms
61,636 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);
		for (int i = 1; i < 10000; ++i) {
			ret -= Math.cos(x + i + 0.5) / (x + i + 1) / (x + i);
			ret -= Math.cos(-x + i + 0.5) / (-x + i + 1) / (-x + i);
		}
		ret *= 0.5 / Math.sin(0.5);
		ret += sinc(x);
		return a * ret;
	}

	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