You are viewing a single comment's thread. Return to all comments →
I don't now whether anyone is interested, but there is a way to solve the problem even if you don't know about gcd :
#include <set> #include <iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int N; cin >> N; set<int> s; for (int i = 0; i < N; i++) { int a; cin >> a; s.insert(a); } bool divisor_exists = false; for (int d = 2; d <= 100000; d++) { int cnt = 0; for (int a : s) cnt += (a % d == 0); if (cnt == s.size()) { divisor_exists = true; break; } } cout << (divisor_exists ? "NO" : "YES") << '\n'; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and GCD
You are viewing a single comment's thread. Return to all comments →
I don't now whether anyone is interested, but there is a way to solve the problem even if you don't know about gcd :