結果
問題 | No.347 微分と積分 |
ユーザー |
|
提出日時 | 2016-02-27 17:04:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 756 ms |
コンパイル使用メモリ | 74,724 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 11:41:16 |
合計ジャッジ時間 | 1,508 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <string> #include <vector> static double differential(int b, const std::vector<double>& as); static double integral(int b, const std::vector<double>& as); static constexpr double EPS = 1.0e-9; int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); int n, b; std::cin >> n >> b; std::vector<double> as(n); for (auto& a : as) { std::cin >> a; } std::cout << std::fixed << std::setprecision(4) << differential(b, as) << '\n' << integral(b, as) << std::endl; return EXIT_SUCCESS; } static double differential(int b, const std::vector<double>& as) { double sum = 0.0; for (const auto& a : as) { sum += a * std::pow(b, a - 1); } return sum; } static double integral(int b, const std::vector<double>& as) { double sum = 0.0; for (const auto& a : as) { sum += std::abs(a + 1.0) < EPS ? std::log(b) : std::pow(b, a + 1) / (a + 1); } return sum; }