My issue
Why is it going tle?
My code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_prime(ll n) {
if (n <= 1) {
return false;
}
if (n == 2) {
return true;
}
if (n%2 == 0) {
return false;
}
for (ll i = 3; i*i <= n; i+=2) {
if (n%i == 0) {
return false;
}
}
return true;
}
int main() {
int t;
cin >> t;
while (t--) {
ll x,y;
cin >> x >> y;
ll z = x^y;
ll a = 2;
ll b = 2^x;
ll c = 2^z;
if (is_prime(b) and is_prime(c)) {
cout << 2 << " " << min(b,c) << " " << max(b,c) << endl;
continue;
}
b = 2;
a = 2^x;
c = 2^y;
if (is_prime(a) and is_prime(c)) {
cout << 2 << " " << min(a,c) << " " << max(a,c) << endl;
continue;
}
c = 2;
a = 2^z;
b = 2^y;
if (is_prime(a) and is_prime(b)) {
cout << 2 << " " << min(a,b) << " " << max(a,b) << endl;
continue;
}
}
return 0;
}
Problem Link: PRIME_XOR Problem - CodeChef