498-bis
这题在 zeorjudge 上怪怪的,我在网路上找了 online judge 与其他的测值都是AC,结果在 zerojudge 上却 NA,有知道的大老可以帮我看看ㄇXD题目连结
简单来说就是把方程式微分,求带入 X 后的答案
解题
题目没有讲什么结束读取方程式(不知到有几项)次方会比较推荐用一项项的乘(pow我不确定会不会爆)方便取次方的导数==> reverse 阵列用
cin
与getchar()
来取值 当输入一个值后,如果后面不是打空格就退出
这样会导致最后一项(常数项)没有存入,没关西因为常数的导数是0
code
#include <iostream>#include <string>#include <vector>#include <algorithm>#define ll long long intusing namespace std;int main(){ int x; while (cin >> x) { string s; ll a; getline(cin, s); vector<ll> function; while (cin >> a && getchar() == ' ') function.push_back(a); reverse(function.begin(), function.end()); ll tem = 1; ll ans = 0; for (int i = 0; i < function.size(); i++) { ans += function[i] * (i + 1) * tem; tem *= x; } cout << ans << endl; function.clear(); }}