利用了哥德巴赫的两个定理
任何一个大于2的偶数都可以写成两个素数之和,
任何一个大于5的整数都可以写成三个素数之和。
以及一个推论
存在大于5的整数可以写为2和一个素数之和(这是推论)
代码如下
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
bool isprime(ll n){
if(n < 2) return false;
for(ll i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return true;
}
int solve(ll n){
if(isprime(n)) return 1;
else if((n % 2 == 0) || isprime(n-2)) return 2;
else return 3;
}
int main(void){
int t;
ll n;
scanf("%d",&t);
while(t--) {
scanf("%lld",&n);
printf("%d\n",solve(n));
}
return 0;
}