結果

問題 No.347 微分と積分
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-21 20:45:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 699 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 71,240 KB
実行使用メモリ 56,480 KB
最終ジャッジ日時 2023-08-18 06:12:31
合計ジャッジ時間 6,697 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
55,688 KB
testcase_01 AC 139 ms
56,060 KB
testcase_02 AC 140 ms
56,148 KB
testcase_03 AC 139 ms
56,480 KB
testcase_04 AC 141 ms
55,896 KB
testcase_05 AC 138 ms
55,956 KB
testcase_06 AC 139 ms
55,712 KB
testcase_07 AC 141 ms
55,940 KB
testcase_08 AC 139 ms
55,716 KB
testcase_09 AC 138 ms
55,832 KB
testcase_10 AC 142 ms
56,148 KB
testcase_11 AC 139 ms
55,952 KB
testcase_12 AC 139 ms
55,904 KB
testcase_13 AC 141 ms
55,980 KB
testcase_14 AC 140 ms
55,948 KB
testcase_15 AC 140 ms
55,652 KB
testcase_16 AC 141 ms
55,932 KB
testcase_17 AC 140 ms
55,864 KB
testcase_18 AC 143 ms
55,976 KB
testcase_19 AC 142 ms
56,244 KB
testcase_20 AC 141 ms
55,976 KB
testcase_21 AC 142 ms
56,348 KB
testcase_22 AC 140 ms
56,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    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 fb=0;
        for(int i=0; i<N; i++){
            fb+=A[i]*(Math.pow(B,A[i]-1));
        }
        System.out.println(fb);
        
        double FB=0;
        for(int i=0; i<N; i++){
            if(A[i]==-1.0){
                FB+=Math.log(B);
            }else{
                FB+=(Math.pow(B,A[i]+1))/(A[i]+1);
            }
        }
        System.out.println(FB);
    }
}
0