This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
using namespace std;
int gcd (int a,int b) {
if (!b) return a;
return gcd (b, a%b);
}
int main() {
int n, q;
cin >> n >> q;
vector<int> v (n+1);
while (q--) {
char t;
cin >> t;
if (t == 'C') {
int x, y;
cin >> x >> y;
bool ok = false;
for (int i = x;i <= y; ++i) {
for (int j = i+1; j<=y;++j){
if (v[i]&&v[j]&&gcd (i, j) > 1) ok = true;
}
}
if (ok) cout << "DA\n";
else cout << "NE\n";
} else {
int x;
cin >> x;
v[x] = 1-v[x];
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |