結果

問題 No.347 微分と積分
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-22 15:03:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 157 ms / 5,000 ms
コード長 667 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 74,156 KB
実行使用メモリ 57,884 KB
最終ジャッジ日時 2023-10-19 07:16:02
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
57,584 KB
testcase_01 AC 156 ms
57,572 KB
testcase_02 AC 151 ms
55,788 KB
testcase_03 AC 152 ms
57,744 KB
testcase_04 AC 151 ms
57,780 KB
testcase_05 AC 149 ms
57,616 KB
testcase_06 AC 149 ms
57,704 KB
testcase_07 AC 152 ms
57,708 KB
testcase_08 AC 151 ms
57,700 KB
testcase_09 AC 152 ms
57,708 KB
testcase_10 AC 154 ms
57,700 KB
testcase_11 AC 156 ms
57,664 KB
testcase_12 AC 155 ms
57,672 KB
testcase_13 AC 152 ms
57,736 KB
testcase_14 AC 151 ms
57,768 KB
testcase_15 AC 154 ms
57,736 KB
testcase_16 AC 154 ms
57,884 KB
testcase_17 AC 154 ms
57,708 KB
testcase_18 AC 156 ms
57,848 KB
testcase_19 AC 157 ms
57,712 KB
testcase_20 AC 150 ms
57,740 KB
testcase_21 AC 157 ms
57,800 KB
testcase_22 AC 153 ms
57,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double b = sc.nextDouble();
    double[] a = new double[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextDouble();
    }
    double ans1 = 0;
    double ans2 = 0;
    for(int i = 0; i < n; i++) {
      if(a[i] != 0) {
        ans1 += (a[i] * (double)Math.pow(b, a[i] - 1));
      }
      if(a[i] == -1) {
        ans2 += (double)Math.log(b);
      } else {
        ans2 += ((1 / (a[i] + 1)) * (double)Math.pow(b, a[i] + 1));
      }
    }
    System.out.println(ans1);
    System.out.println(ans2);
  }
}
0