結果

問題 No.347 微分と積分
ユーザー sugim48sugim48
提出日時 2016-02-26 22:33:16
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 455 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 55,824 KB
最終ジャッジ日時 2023-10-23 20:31:54
合計ジャッジ時間 840 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:29: error: ‘pow’ was not declared in this scope
   17 |                 x += a[i] * pow(B, a[i] - 1);
      |                             ^~~
main.cpp:18:38: error: ‘log’ was not declared in this scope; did you mean ‘long’?
   18 |                 if (a[i] == -1) y += log((double)B);
      |                                      ^~~
      |                                      long

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
	int N, B; cin >> N >> B;
	vector<double> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];
	double x = 0, y = 0;
	for (int i = 0; i < N; i++) {
		x += a[i] * pow(B, a[i] - 1);
		if (a[i] == -1) y += log((double)B);
		else y += 1 / (a[i] + 1) * pow(B, a[i] + 1);
	}
	cout << x << endl << y << endl;
}
0