①如果一个数为偶数,那么可以拆成两个质数相加
②如果一个奇数 (n-2)为质数那么他也可以拆成两个质数相加(2+(n-2))。例如25=2+23。
③其他的奇数可以拆成一个 质数+一个偶数,也就是 3个质数相加。
思路:答案就是1,2,3三种情况,根据哥德巴赫猜想讨论一下即可。
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
using namespace std;
const int INF = 0x3f3f3f3f;//?????
typedef long long ll;
typedef long double ld;
typedef pair<ll, int> pll;
typedef pair<int, int> pii;
const int N = 1e5+5;
int a[55],b[55],color[N],st[N];ll sum[N];
int cnt;
ll qpow(ll x,ll y,ll mod)
{
int ans=1;
while(y)
{
if(y&1) ans=ans*x%mod;
x=x*x%mod;
y>>=1;
}
return ans%mod;
}
int prime(int n)
{
for(int i=2;i*i<=n;i++)
{
if(n%i==0) return 0;
}
return 1;
}
int main()
{
IOS;
int n; cin >> n;
int flag=0;flag=prime(n);
if(flag==1)
{
cout << 1 << endl;
}
else
{
if(n%2==0) {
cout << 2 << endl;
}
else
{
flag=0;
flag=prime(n-2);
if(flag) cout << 2 << endl;
else cout << 3 << endl;
}
}
return 0;
} 
京公网安备 11010502036488号