存代码:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
#define M1 100007
#define M2 22901
#define M3 22907
#define Maxm 1000010
#define Maxn 110
#define Maxd 10010
#define LL long long int n,m; LL a[][Maxn];
char s[Maxd]; int op[Maxm]; int mymin(int x,int y) {return x<y?x:y;} bool check(LL x)
{
LL a1=,a2=,a3=;
for(int i=n;i>=;i--)
{
a1=(a1*x+a[][i])%M1;
a2=(a2*x+a[][i])%M2;
a3=(a3*x+a[][i])%M3;
}
return a1==&&a2==&&a3==;
} bool ok[]; int main()
{
int l;
scanf("%lld%lld",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%s",s);
l=strlen(s);
a[][i]=a[][i]=;
int f=;
for(int j=;j<l;j++)
{
if(s[j]=='-') {f=-;continue;}
a[][i]=(a[][i]*+s[j]-'')%M1;
a[][i]=(a[][i]*+s[j]-'')%M2;
a[][i]=(a[][i]*+s[j]-'')%M3;
}
a[][i]*=f;a[][i]*=f;a[][i]*=f;
}
op[]=;
int cnt=;
memset(ok,,sizeof(ok));
for(int i=;i<=m;i++)
{
if(check((LL)i)) op[++op[]]=i;//,ok[i]=1;
// if(op[0]>n) break;
}
/*for(int i=mymin(100000,m)+1;i<=m;i++)
{
if(ok[i%M1]&&ok[i%M2]&&ok[i%M3]) op[++op[0]]=i;
}*/
printf("%d\n",op[]);
for(LL i=;i<=op[];i++) printf("%d\n",op[i]);
return ;
}