题意:已知k和一个集合C={c1,c2,c3....cn},问是否有满足集合C的中国剩余定理的解x,使x%k的值唯一确定。
数学知识:
#include<iostream> #include<cstdio> using namespace std; #define LL long long LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); } int main(){ int n, m; cin >> n >> m; LL ans = 1, res; while (n--){ scanf("%I64d", &res); ans = ans/gcd(res, ans)*res%m; } if (ans%m)cout << "No" << endl; else cout << "Yes" << endl; }