結果

問題 No.347 微分と積分
ユーザー takeya_okino
提出日時 2019-09-22 15:03:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 667 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 74,352 KB
実行使用メモリ 41,708 KB
最終ジャッジ日時 2024-09-19 03:36:29
合計ジャッジ時間 5,591 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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