思路:因为给的数太大,高精比较慢,所以用f(x)==0的必要条件f(x)%mod==0,然后应为出差的概率很小(具体多小我也不知道)
然后就可以直接全部取膜;
疑问(待解决):为什么用100000007模不行,用1000000007就对了呢?
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<vector> #define mem(a) memset((a),0,sizeof((a))); #define rep(i,init,max) for(int i=(init);i<(max);i++) #define mod 1000000007 using namespace std; typedef long long LL; const double PI =acos(-1.0); #define eps 1e-8 const int maxn=10000; int nx[101],ansn[100000]; LL read() { char x; LL ret;int f=1; while(x!=‘-‘&&(x<‘0‘||x>‘9‘))x=getchar(); if(x==‘-‘){ f=-1; x=getchar(); } if(x==‘0‘) return 0; else ret=x-‘0‘; for(x=getchar();x!=‘\n‘;x=getchar()){ ret=(ret*10+x-‘0‘)%mod; } return f*ret; } bool judge(int x,int len) { LL sum=0; for(int i=len-1;i>=0;i--) sum=(sum*x+nx[i])%mod; if(sum!=0)return false; else return true; } int main() { // freopen("testdata.in","r",stdin); int n,m,ans=0,la=0; cin>>n>>m; m++;n++; if(n==1){ ans=read(); if(ans==0)printf("%d",0); else { printf("%d",m-1); rep(i,1,m)printf("%d\n",i); } return 0; } rep(i,0,n)nx[i]=read(); rep(i,1,m){ if(judge(i,n)){ ans++; ansn[la++]=i; } } cout<<ans<<endl; rep(i,0,la)printf("%d\n",ansn[i]); return 0; }