結果

問題 No.347 微分と積分
ユーザー gu_21816943gu_21816943
提出日時 2017-06-28 00:15:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 862 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 77,632 KB
実行使用メモリ 50,788 KB
最終ジャッジ日時 2024-04-15 03:37:55
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,480 KB
testcase_01 AC 51 ms
50,680 KB
testcase_02 AC 53 ms
50,464 KB
testcase_03 AC 52 ms
50,788 KB
testcase_04 AC 52 ms
50,676 KB
testcase_05 AC 52 ms
50,584 KB
testcase_06 AC 50 ms
50,616 KB
testcase_07 AC 51 ms
50,480 KB
testcase_08 AC 51 ms
50,308 KB
testcase_09 AC 50 ms
50,660 KB
testcase_10 AC 51 ms
50,632 KB
testcase_11 AC 50 ms
50,692 KB
testcase_12 AC 50 ms
50,588 KB
testcase_13 AC 50 ms
50,168 KB
testcase_14 AC 51 ms
50,468 KB
testcase_15 AC 50 ms
50,684 KB
testcase_16 AC 51 ms
50,156 KB
testcase_17 AC 50 ms
50,340 KB
testcase_18 AC 52 ms
50,688 KB
testcase_19 AC 51 ms
50,604 KB
testcase_20 AC 51 ms
50,480 KB
testcase_21 AC 49 ms
50,172 KB
testcase_22 AC 51 ms
50,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
	static PrintWriter out = new PrintWriter(System.out);
	static String str;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int len = Integer.parseInt(br.readLine());
		int B = Integer.parseInt(br.readLine());
		String[] str=br.readLine().split(" ");
		double[] num=new double[len];
		for(int i=0;i<len;i++){
			num[i]=Double.parseDouble(str[i]);
		}
		double sum=0;
		for(int i=0;i<len;i++){
			sum+=num[i]*Math.pow(B, num[i]-1);
		}
		System.out.println(sum);

		sum=0;
		for(int i=0;i<len;i++){
			if(num[i]==-1.0){
				sum+=Math.log(B);
			}else{
				sum+=Math.pow(B, num[i]+1)/(num[i]+1);
			}
		}
		System.out.println(sum);


	}
}
0