結果

問題 No.347 微分と積分
ユーザー YamaKasaYamaKasa
提出日時 2018-09-17 03:58:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 1,807 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 42,188 KB
最終ジャッジ日時 2024-07-18 07:34:53
合計ジャッジ時間 5,662 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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