結果
問題 | No.347 微分と積分 |
ユーザー |
|
提出日時 | 2020-08-26 12:13:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 2,207 ms |
コンパイル使用メモリ | 194,288 KB |
最終ジャッジ日時 | 2025-01-13 14:58:06 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,n) for(int i=0; i<(int)(n); i++)#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)#define ALL(x) (x).begin(), (x).end()const double PI = acos(-1);double f(const vector<double> &a, double b) {double ret = 0;REP (i, a.size())ret += a[i] * pow(b, a[i]-1);return ret;}double F(const vector<double> &a, double b) {double ret = 0;REP (i, a.size()) {if (a[i] == -1)ret += log(b);elseret += 1.0 / (a[i]+1) * pow(b, a[i]+1);}return ret;}int main() {ios_base::sync_with_stdio(0);cin.tie(0);int n;double b;cin >> n >> b;vector<double> a(n);REP (i, n) cin >> a[i];cout << fixed << setprecision(12);cout << f(a, b) << endl;cout << F(a, b) << endl;return 0;}