2025 Taiwan Online
Programming Contest
A. Take It or Double It
Problem: A. Take It or Double It
Solution: GitHub
Code
1 2 3 4 5 6 7 8 9 10
| 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 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;
}
|