結果

問題 No.347 微分と積分
ユーザー uafr_csuafr_cs
提出日時 2016-02-26 23:13:09
言語 Java19
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 956 bytes
コンパイル時間 2,899 ms
コンパイル使用メモリ 79,048 KB
実行使用メモリ 57,844 KB
最終ジャッジ日時 2023-10-24 06:07:54
合計ジャッジ時間 7,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
57,816 KB
testcase_01 AC 141 ms
57,700 KB
testcase_02 AC 141 ms
57,840 KB
testcase_03 AC 137 ms
57,548 KB
testcase_04 AC 140 ms
57,600 KB
testcase_05 AC 139 ms
57,524 KB
testcase_06 AC 142 ms
57,788 KB
testcase_07 AC 143 ms
57,844 KB
testcase_08 AC 142 ms
57,820 KB
testcase_09 AC 140 ms
56,096 KB
testcase_10 AC 141 ms
57,492 KB
testcase_11 AC 142 ms
57,804 KB
testcase_12 AC 142 ms
57,808 KB
testcase_13 AC 144 ms
57,800 KB
testcase_14 AC 144 ms
57,540 KB
testcase_15 AC 146 ms
57,460 KB
testcase_16 AC 143 ms
57,836 KB
testcase_17 AC 147 ms
57,700 KB
testcase_18 AC 144 ms
57,756 KB
testcase_19 AC 148 ms
57,776 KB
testcase_20 AC 143 ms
57,792 KB
testcase_21 AC 145 ms
57,800 KB
testcase_22 AC 141 ms
56,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static final double EPS= 1e-7;
	
	public static double differentiate(final double x, double[] bs){
		double ret = 0;
		for(final double b : bs){
			ret += b * Math.pow(x, b - 1);
		}
		return ret;
	}
	
	public static double integrate(final double x, double[] bs){
		double ret = 0;
		for(final double b : bs){
			if(Math.abs(b + 1) < EPS){
				ret += Math.log(x);
			}else{
				ret += Math.pow(x, b + 1) / (b + 1);
			}
		}
		return ret;
	}

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int B = sc.nextInt();
		
		double[] bs = new double[N];
		for(int i = 0; i < N; i++){
			bs[i] = sc.nextDouble();
		}
		
		System.out.printf("%.8f\n", differentiate(B, bs));
		System.out.printf("%.8f\n", integrate(B, bs));
		
	}

}
0