- 题意 :
f
(
x
)
f(x)
f(x)是严格大于x的最小质数,
g
(
x
)
=
[
f
(
x
)
+
f
(
f
(
x
)
)
]
/
2
g(x)=[f(x)+f(f(x))]/2
g(x)=[f(x)+f(f(x))]/2的向下取整,判断
g
(
x
)
g(x)
g(x)是否是质数
- 思路 :f(f(x))即f(x)相邻的下一个质数,g(x)在相邻两个质数之间,所以g(x)一定是合数,除了x=1的情况下,f(1)=2,f(2)=3,即除了2和3之间以外
- 语法 :long long 9e18多,int 2e9多
#include
#define endl 'n'
using namespace std;
typedef long long ll;
int main()
{
int T;
cin >> T;
while (T -- )
{
ll x;
cin >> x;
if (x == 1) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}
//打表
#include
using namespace std;
typedef long long LL;
const int maxn = 1e9+10;
int is_prime(LL x){
for(LL i = 2; i*i <= x; i++){
if(x%i==0){
return 0;
}
}
return 1;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T; cin>>T;
while(T--){
LL x=T; // cin>>x;
LL i;
for(i = x+1; ; i++){
if(is_prime(i)){
break;
}
}
LL j;
for(j = i+1; ; j++){
if(is_prime(j)){
break;
}
}
LL k = (i+j)/2;
if(is_prime(k))cout<<"YESn";
else cout<<"NOn";
}
return 0;
}