結果

問題 No.347 微分と積分
ユーザー htensaihtensai
提出日時 2019-11-21 18:11:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 5,000 ms
コード長 619 bytes
コンパイル時間 2,480 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 42,040 KB
最終ジャッジ日時 2024-04-19 03:01:36
合計ジャッジ時間 6,737 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
42,040 KB
testcase_01 AC 146 ms
41,672 KB
testcase_02 AC 119 ms
40,168 KB
testcase_03 AC 141 ms
41,004 KB
testcase_04 AC 140 ms
40,988 KB
testcase_05 AC 143 ms
41,268 KB
testcase_06 AC 143 ms
40,416 KB
testcase_07 AC 144 ms
40,896 KB
testcase_08 AC 145 ms
41,772 KB
testcase_09 AC 138 ms
41,452 KB
testcase_10 AC 151 ms
41,700 KB
testcase_11 AC 144 ms
41,260 KB
testcase_12 AC 145 ms
41,292 KB
testcase_13 AC 128 ms
41,376 KB
testcase_14 AC 145 ms
41,376 KB
testcase_15 AC 143 ms
41,144 KB
testcase_16 AC 140 ms
41,412 KB
testcase_17 AC 144 ms
40,864 KB
testcase_18 AC 142 ms
41,736 KB
testcase_19 AC 139 ms
41,304 KB
testcase_20 AC 126 ms
41,048 KB
testcase_21 AC 139 ms
41,148 KB
testcase_22 AC 140 ms
41,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double b = sc.nextInt();
		double[] arr = new double[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextDouble();
		}
		double x1 = 0;
		for (int i = 0; i < n; i++) {
		    x1 += arr[i] * Math.pow(b, arr[i] - 1);
		}
		System.out.println(x1);
		double x2 = 0;
		for (int i = 0; i < n; i++) {
		    if (arr[i] == -1.0) {
		        x2 += Math.log(b);
		    } else {
		        x2 += Math.pow(b, arr[i] + 1) / (arr[i] + 1);
		    }
		}
		System.out.println(x2);
	}
}
0