题解 | #多项式的值#

多项式的值

https://www.nowcoder.com/practice/13634a38c0eb4b9db8701953ed453567

#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int n;cin>>n;
    while(n--){
        int maxPow;cin>>maxPow;
        int arr[maxPow+1];
        for(int i =0;i<=maxPow;i++)
            cin>>arr[i];
        int x;cin>>x;
        int res = 0;
        for(int i =0;i<=maxPow;i++){
            res+=arr[i]*pow(x,i);
        }
        cout<<res<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

Yki_:以下条件优先录用: 喜欢去缅北当猪仔的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务