虽然我提交了7次才AC
2025-02-10 21:09:08
发布于:江苏
7阅读
0回复
0点赞
#include <bits/stdc++.h>
int T;
bool is_prime (long long n) {
if(n == 1) return false;
for (int i = 2;i <= sqrt(n);i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
int main(){
std::cin >> T;
while (T--) {
long long a, b;
std::cin >> a >> b;
if (a == 1){
if(is_prime(b)) {
std::cout << "YES";
}
else {
std::cout << "NO";
}
}
else if (b == 1){
if(is_prime(a)) {
std::cout << "YES";
}
else {
std::cout << "NO";
}
}
else {
std::cout << "NO";
}
std::cout << std::endl;
}
}
这里空空如也
有帮助,赞一个