30pts代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10,mod=1e9+9;
int re(){
int n=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;
c=getchar();
}
while(c>='0'&&c<='9')n=n*10+c-'0',n%=mod,c=getchar();
return n*f;
}
int a[110];
int ans[N],tot;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
for(int i=0;i<=n;i++){
string s;
cin>>s;
int t=0;
if(s[0]=='-') a[i]=-1,t=1;
else a[i]=1;
a[i]*=s[s.size()-1]-'0';
for(int j=s.size()-2;j>=t;j--){
a[i]=(a[i]*10+s[j]-'0')%mod;
}
}
for(int i=1;i<=m;i++){
int sum=a[n];
for(int j=1;j<=n;j++){
sum=(sum*i%mod+a[n-j])%mod;
}
if(sum==0) ans[++tot]=i;
}
cout<<tot<<"\n";
for(int i=1;i<=tot;i++) cout<<ans[i]<<"\n";
return 0;
}
必关