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\n",num[i]); }
标签:const,int,sum,P2312,read,解方程,ll,getchar 来源: https://www.cnblogs.com/SFWR-YOU/p/10969671.html