結果

問題 No.347 微分と積分
ユーザー 37zigen37zigen
提出日時 2016-04-11 19:22:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 636 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 74,520 KB
実行使用メモリ 54,568 KB
最終ジャッジ日時 2024-04-15 00:18:06
合計ジャッジ時間 6,645 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
54,316 KB
testcase_01 AC 144 ms
54,444 KB
testcase_02 AC 143 ms
54,380 KB
testcase_03 AC 144 ms
54,156 KB
testcase_04 AC 142 ms
54,400 KB
testcase_05 AC 142 ms
54,296 KB
testcase_06 AC 145 ms
54,568 KB
testcase_07 AC 148 ms
54,340 KB
testcase_08 AC 144 ms
54,312 KB
testcase_09 AC 143 ms
54,392 KB
testcase_10 AC 145 ms
54,204 KB
testcase_11 AC 144 ms
54,320 KB
testcase_12 AC 145 ms
54,084 KB
testcase_13 AC 129 ms
53,500 KB
testcase_14 AC 144 ms
54,256 KB
testcase_15 AC 144 ms
54,252 KB
testcase_16 AC 137 ms
54,200 KB
testcase_17 AC 146 ms
54,384 KB
testcase_18 AC 145 ms
54,568 KB
testcase_19 AC 144 ms
54,504 KB
testcase_20 AC 147 ms
54,560 KB
testcase_21 AC 143 ms
54,032 KB
testcase_22 AC 144 ms
54,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		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 f=0,F=0;
		for(int i=0;i<n;i++){
			f+=a[i]*Math.pow(b, a[i]-1);
			if(a[i]==-1){
				F+=Math.log((b));
			}else{
				F+=Math.pow(b, a[i]+1)/(a[i]+1);
			}
		}
		System.out.println(f);
		System.out.println(F);
	}
	//a^n
//	double pow(double a,double n){
//		if(n<0)return 1/Math.pow(a,n);
//		else return Math.pow(a, n);
//	}
}
0