結果

問題 No.347 微分と積分
ユーザー aaaaasatori
提出日時 2018-02-20 23:21:51
言語 Java
(openjdk 23)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 3,575 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 54,500 KB
最終ジャッジ日時 2024-09-13 13:01:00
合計ジャッジ時間 7,960 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No347 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int B = sc.nextInt();
		double a[] = new double[N];
		for(int i = 0;i < N;i++) {
			a[i] = sc.nextDouble();
		}
		double fbibun[] = new double[N];
		double fsekibun[] = new double[N];
		double sumbibun = 0;
		double sumsekibun = 0;
		
		for(int i = 0;i < N;i++) {
			if(a[i] != 0) {
				sumbibun += a[i] * Math.pow(B, a[i]-1);
			}
			if(a[i] != -1) {
				sumsekibun += Math.pow(B, a[i]+1) / (a[i]+1);
			}else if(a[i] == -1) {
				sumsekibun += Math.log(B);
			}
		}
		
		System.out.println(sumbibun);
		System.out.println(sumsekibun);
	}
}
0