题目链接:Problem - 7129
Problem Description
A positive integer is called a prime if it is greater than 1 and cannot be written as the product of two smaller positive integers. A primality test is an algorithm for determining whether an input number is a prime. For example, the Miller-Rabin primality test is a probabilistic primality test. This problem is precisely the one about the primality test.
Let's define the function f(x) as the smallest prime which is strictly larger than x. For example, f(1)=2, f(2)=3, and f(3)=f(4)=5. And we use ⌊x⌋ to indicate the largest integer that does not exceed x.
Now given x, please determine whether g(x) is a prime.
g(x)=⌊f(x)+f(f(x))2⌋
Input
The first line of the input contains an integer T (1≤T≤105), indicating the number of test cases.
Each test case contains an integer x (1≤x≤1018) in a single line.
Output
For each test case, if g(x) is a prime, output YES in a single line. Otherwise, output NO in a single line.
Sample Input
2
1
2
Sample Output
YES
NO
题意:f(x) = 大于x的最小素数
然后判断g(x)是否为素数
思路:只有x==1的时候g(x)= 2 为素数
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
long long n;
cin >> n;
if(n == 1){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
return 0;
}