Skip to content

2025 TOPC

2025 Taiwan Online Programming Contest

A. Take It or Double It

Problem: A. Take It or Double It

Solution: GitHub Code

cpp
void solve() {
    int x, d;
    cin >> x >> d;

    if(x*2>d){
        cout << "take it" << endl;
    }else{
        cout << "double it" << endl;
    }
}

B. Twin Guardians

Problem: B. Twin Guardians

Solution: GitHub Code

cpp
void solve() {
    int a,b;
    cin >> a >> b;
    bool check = true;
    if(b-a != 2) check = false;
    else if(a == 1) check = false;
    else{
        for(int i=2;i*i<=a;i++){
            if(a%i == 0){
                check = false;
                break;
            }
        }
        for(int i=2;i*i<=b;i++){
            if(b%i == 0){
                check = false;
                break;
            }
        }
    }
    if(check) cout << "Y" << endl;
    else cout << "N" << endl;

}