結果
| 問題 |
No.347 微分と積分
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-11 19:22:40 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 5,000 ms |
| コード長 | 636 bytes |
| コンパイル時間 | 1,753 ms |
| コンパイル使用メモリ | 78,544 KB |
| 実行使用メモリ | 42,092 KB |
| 最終ジャッジ日時 | 2024-10-04 06:34:18 |
| 合計ジャッジ時間 | 5,718 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
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);
// }
}