您当前的位置: 首页 > 

先求一个导

暂无认证

  • 4浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

多项式求值(秦九韶模板)

先求一个导 发布时间:2021-03-06 09:37:00 ,浏览量:4

https://ac.nowcoder.com/acm/contest/11164/B

原理:在这里插入图片描述

//秦九韶算法
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int mod = 998244353;
const int N = 1e3+10;
int n,m,a[N];
void fun()
{
    OldTomato;
    cin>>n;
    for(int i=0;i>a[i];
    cin>>m;
    while(m--)
    {
       int x;cin>>x;
       long long ans = 0; //循环n+1次,a[n]表征anxn,第一次+a[n],接下来的n次循环都包含a[n]*x,自然变成了anxn.
       for(int i=n;i>=0;--i) ans = (ans*x+a[i])%mod; //core.
       cout            
关注
打赏
1662037414
查看更多评论
0.0357s