码迷,mamicode.com
首页 > 其他好文 > 详细

excrt——cf687b

时间:2019-08-29 16:24:06      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:gcd   lcm   turn   code   cstring   ons   class   can   printf   

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");
}

 

excrt——cf687b

标签:gcd   lcm   turn   code   cstring   ons   class   can   printf   

原文地址:https://www.cnblogs.com/zsben991126/p/11429705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!