题意:
给你n和k,表示有n个数,c1到cn,然后让你求一个数x,可以告诉你x%ci的值,问你是否可以唯一确定一个x%k的值
题解:
反证:
假设有两个x1,x2同时是解,则对于所有ci,x1%ci==x2%ci&&x1%k!=x2%k,及(x1-x2)%ci==0&&(x1-x2)%k!=0,
及x1-x2==nlcm(ci)(n属于1到无穷大),所以对于所有的n,nlcm(ci)%k!=0,显而易见所有的nlcm%k!=0的话,则lcm%k!=0,
所以可以得出存在两个解的话,lcm%k!=0
所以我们只要判断lcm%k是否等于零即可
#include<bits/stdc++.h> #define de(x) cout<<#x<<"="<<x<<endl; #define dd(x) cout<<#x<<"="<<x<<" "; #define rep(i,a,b) for(int i=a;i<(b);++i) #define repd(i,a,b) for(int i=a;i>=(b);--i) #define repp(i,a,b,t) for(int i=a;i<(b);i+=t) #define ll long long #define mt(a,b) memset(a,b,sizeof(a)) #define fi first #define se second #define inf 0x3f3f3f3f #define INF 0x3f3f3f3f3f3f3f3f #define pii pair<int,int> #define pdd pair<double,double> #define pdi pair<double,int> #define mp(u,v) make_pair(u,v) #define sz(a) a.size() #define ull unsigned long long #define ll long long #define pb push_back #define PI acos(-1.0) #define qc std::ios::sync_with_stdio(false) #define db double const int mod = 1e9+7; const int maxn = 1e6+5; const double eps = 1e-6; using namespace std; bool eq(const db &a, const db &b) { return fabs(a - b) < eps; } bool ls(const db &a, const db &b) { return a + eps < b; } bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); } ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); }; ll lcm(ll a,ll b) { return a/gcd(a,b)*b; } ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll read(){ ll x=0,f=1;char ch=getchar(); while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } //inv[1]=1; //for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod; int n,k; ll c[maxn]; bool ok(){ ll ans = c[1]; rep(i,2,n+1) ans = lcm(ans,c[i]) % k; ans %= k; return !ans; } int main(){ scanf("%d%d",&n,&k); rep(i,1,n+1) scanf("%lld",&c[i]); puts(ok()?"Yes":"No"); return 0; }