結果

問題 No.347 微分と積分
ユーザー h_nosonh_noson
提出日時 2016-03-14 10:57:47
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 627 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 61,104 KB
最終ジャッジ日時 2024-04-27 02:18:04
合計ジャッジ時間 752 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:27: error: ‘pow’ was not declared in this scope
   23 |     rep (i,n) x += a[i] * pow(b,a[i]-1);
      |                           ^~~
main.cpp:26:35: error: ‘log’ was not declared in this scope; did you mean ‘long’?
   26 |     rep (i,n) x += (a[i] == -1) ? log(b) : pow(b,a[i]+1) / (a[i]+1);
      |                                   ^~~
      |                                   long
main.cpp:26:44: error: ‘pow’ was not declared in this scope
   26 |     rep (i,n) x += (a[i] == -1) ? log(b) : pow(b,a[i]+1) / (a[i]+1);
      |                                            ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int main() {
    int i, n, b;
    double x;
    double a[10];
    cin >> n >> b;
    cout << fixed << setprecision(5);
    rep (i,n) cin >> a[i];
    x = 0;
    rep (i,n) x += a[i] * pow(b,a[i]-1);
    cout << x << endl;
    x = 0;
    rep (i,n) x += (a[i] == -1) ? log(b) : pow(b,a[i]+1) / (a[i]+1);
    cout << x << endl;
    return 0;
}
0