您的位置:首页 > 其它

codeforces 688D

2016-07-25 12:21 281 查看
题意:已知n个数的模后的结果,求另外一个数模的结果。

题解:中国剩余定理的入门题。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
int n,m;
while(scanf(" %d %d",&n,&m)==2){
LL ret=1;
for(int i=0;i<n;i++){
int x;
scanf(" %d",&x);
ret = ret/__gcd(x+0ll,ret)*x;
ret = __gcd(m+0ll,ret);
}
if(ret==m){
printf("Yes\n");
}else{
printf("No\n");
}
}
return 0;
}
/*
3 0 10 17 15 2
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息