excrt——cf687b

excrt的理解

问对于方程组x = ai % ci 的 通解 x+tM, (x+tM) % k 是否有唯一值 

看tm%k是否==0即可

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int maxn = 1e5+100;
typedef long long LL;
LL gcd(LL a,LL b) { return b==0 ? a:gcd(b,a%b);}
LL lcm(LL a,LL b){ return a/gcd(a,b)*b; }
int main()
{
    int n,k,a,i;
    scanf("%d%d",&n,&k);
    LL ans=1;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        ans=lcm(ans,a)%k;
    }
    printf("%s\n",ans==0 ? "Yes":"No");
}

 

posted on 2019-08-29 14:54  zsben  阅读(187)  评论(0编辑  收藏  举报

导航