zoukankan      html  css  js  c++  java
  • P2312 解方程

    ——————————————————————————————————————————————————————————————————

    论const 与变量的速度差

    QAQ

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int p=1000000007;
    ll n,m,cnt,a[110],temp=0,num[1000003];
    int flag,sum,i,k,j;
    inline ll read()
    {
        ll sum=0,fg=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-') fg=-1;c=getchar();}
        while(c>='0'&&c<='9'){sum=((sum*10)+c-'0')%p;c=getchar();}
        return sum*fg;
    }
    inline bool calc(int x)
    {
        sum=0;
        for(i=n;i>=1;i--)sum=((a[i]+sum)*x)%p;
        sum=(sum+a[0])%p;
        return !sum;
    }
    int main()
    {
        n=read();m=read();
        for(i=0;i<=n;i++)a[i]=read();
        for(j=1;j<=m;j++)if(calc(j))num[++temp]=j;
        cout<<temp<<endl;
        for(i=1;i<=temp;i++)
        printf("%lld
    ",num[i]);
    }
  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
  • 原文地址:https://www.cnblogs.com/SFWR-YOU/p/10969671.html
Copyright © 2011-2022 走看看