P2312 解方程

a[i]<=10^10000,m<=1e6
a[i]的范围肥肠大!这提醒我们要不取模要不高精(别想了我是不可能写高精的)

but!事情迎来了转机![1,m]的范围比较小,也就是说,我们可以暴力枚举可行的解,用秦九韶公式判断一遍就行了

能取模的依据:若f[x]0 ,则f[x]%p0,按理说应该多模几个质数,可是只模一个就能A掉……懒人先跑了

/*
reference:
	
translation:
	
solution:

trigger:
	
note:
	*
record:

date:
	2019.10.09
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define dwn(i,a,b) for(int i=a;i>=b;--i) 
#define mem(a,b) memset(a,b,sizeof(a))

const int N=1e2+10,mod=1e9+7;
template <typename T>inline void rd(T &x){x=0;char c=getchar();int f=0;while(!isdigit(c)){f|=c=='-';c=getchar();}while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x=f?-x:x;}

int a[N];
int n,m;
int ans[1000010];
int tot;

inline bool check(int x){
	int res=0;
	dwn(i,n,0)
		res=(res*x+a[i])%mod;
	return res==0;
}

#undef int
int main(){
#define int long long
	#ifdef WIN32
	freopen("","r",stdin);
	#endif
	rd(n),rd(m);
	rep(i,0,n)rd(a[i]);
	rep(i,1,m){
		if(check(i)){
			ans[++tot]=i;
		}
	}
	printf("%lld
",tot);
	rep(i,1,tot){
		printf("%lld
",ans[i]);//为啥您写成了i反省一下 
	}
	return 0;
}
原文地址:https://www.cnblogs.com/sjsjsj-minus-Si/p/11643931.html