제출 #644947

#제출 시각아이디문제언어결과실행 시간메모리
644947IwanttobreakfreeRadio (COCI22_radio)C++17
10 / 110
1577 ms724 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...