結果

問題 No.347 微分と積分
ユーザー beet
提出日時 2018-08-01 16:15:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 168,176 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-19 16:46:03
合計ジャッジ時間 2,628 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  Int n;
  double b;
  cin>>n>>b;
  vector<double> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  {
    double res=0;
    for(Int i=0;i<n;i++) res+=pow(b,a[i]-1)*a[i];
    cout<<res<<endl;
  }
  {
    double res=0;
    for(Int i=0;i<n;i++){
      if(a[i]==-1) res+=log(b);
      else res+=pow(b,a[i]+1)/(a[i]+1);
    }
    cout<<res<<endl;
  }
  
  return 0;
}
0