結果

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

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:21: error: ‘pow’ was not declared in this scope
   22 |       res += a[i] * pow((double)B, a[i] - 1.0);
      |                     ^~~
main.cpp:31:37: error: ‘pow’ was not declared in this scope
   31 |         res += 1.0 / (a[i] + 1.0) * pow((double)B, a[i] + 1.0);
      |                                     ^~~
main.cpp:34:16: error: ‘log’ was not declared in this scope; did you mean ‘long’?
   34 |         res += log(B);
      |                ^~~
      |                long

ソースコード

diff #

#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

int main() {

  int N, B;
  double a[64];

  std::cin >> N >> B;
  for(int i = 0; i < N; ++i) {
    std::cin >> a[i];
  }

  {
    double res = 0;
    for(int i = 0; i < N; ++i) {
      res += a[i] * pow((double)B, a[i] - 1.0);
    }
    printf("%.20lf\n", res);
  }

  {
    double res = 0;
    for(int i = 0; i < N; ++i) {
      if( std::abs(a[i] + 1.0) >= 0.001 ) {
        res += 1.0 / (a[i] + 1.0) * pow((double)B, a[i] + 1.0);
      }
      else {
        res += log(B);
      }
    }
    printf("%.20lf\n", res);
  }
  
  return 0;
}
0