結果
問題 | No.347 微分と積分 |
ユーザー |
![]() |
提出日時 | 2016-02-26 23:13:09 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 148 ms / 5,000 ms |
コード長 | 956 bytes |
コンパイル時間 | 2,114 ms |
コンパイル使用メモリ | 78,652 KB |
実行使用メモリ | 54,624 KB |
最終ジャッジ日時 | 2024-09-22 22:58:15 |
合計ジャッジ時間 | 6,469 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
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)); } }