-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2093C.cpp
More file actions
41 lines (35 loc) · 775 Bytes
/
Copy path2093C.cpp
File metadata and controls
41 lines (35 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define umap unordered_map
#define f(i, x, n) for (ll i = x; i < n; i++)
#define endl '\n'
#define optimize() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
bool isPrime(ll x) {
if (x == 1 || x == 0) return false;
else if (x == 2 || x == 3) return true;
else {
for (ll i = 2; i*i <= x; i++) {
if(x%i==0) return false;
}
return true;
}
}
int main() {
optimize();
int t;
cin >> t;
while(t--) {
ll x, y;
cin >> x >> y;
if (y==1) {
isPrime(x) ? cout << "YES" << endl : cout << "NO" << endl;
} else if (x == 1 && y == 2) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
}