結果

問題 No.347 微分と積分
ユーザー YamaKasaYamaKasa
提出日時 2018-09-17 03:58:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 71,432 KB
実行使用メモリ 56,520 KB
最終ジャッジ日時 2023-09-25 09:16:21
合計ジャッジ時間 6,917 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
56,356 KB
testcase_01 AC 136 ms
56,076 KB
testcase_02 AC 136 ms
55,960 KB
testcase_03 AC 133 ms
56,392 KB
testcase_04 AC 136 ms
56,320 KB
testcase_05 AC 133 ms
56,376 KB
testcase_06 AC 133 ms
55,948 KB
testcase_07 AC 134 ms
56,252 KB
testcase_08 AC 132 ms
56,160 KB
testcase_09 AC 131 ms
56,044 KB
testcase_10 AC 134 ms
54,184 KB
testcase_11 AC 132 ms
56,056 KB
testcase_12 AC 132 ms
56,520 KB
testcase_13 AC 130 ms
56,196 KB
testcase_14 AC 135 ms
54,280 KB
testcase_15 AC 132 ms
56,200 KB
testcase_16 AC 135 ms
56,152 KB
testcase_17 AC 133 ms
56,328 KB
testcase_18 AC 134 ms
55,968 KB
testcase_19 AC 136 ms
56,180 KB
testcase_20 AC 135 ms
55,740 KB
testcase_21 AC 133 ms
55,892 KB
testcase_22 AC 134 ms
56,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int b = scan.nextInt();
		double[] x = new double[n];
		for(int i = 0; i < n; i++) {
			x[i] = scan.nextDouble();
		}
		scan.close();
		double a1 = 0;
		double a2 = 0;
		for(int i = 0; i < n; i++) {
			a1 += x[i] * Math.pow(b, x[i] - 1);
			if(x[i] == -1.0) {
				a2 += Math.log(b);
			}else {
				a2 += Math.pow(b, x[i] + 1) / (x[i] + 1);
			}

		}
		System.out.println(a1);
		System.out.println(a2);
	}
}
0