题目链接:http://codeforces.com/problemset/problem/735/D点击打开链接
举个反例
5616
贪心结果是
5591 23 2
但是可以拆成
5573 43
哥德巴赫猜想啊。。
于是可以分类判断
#include<bits/stdc++.h>
using namespace std;
bool isprime(int n) {
if(n < 2)return false;
for(int i = 2; i * i <= n; i++) {
if(n % i == 0)return false;
}
return true;
}
int main() {
int n;
while(~scanf("%d", &n))
{
if(isprime(n))
printf("1\n");
else if(n % 2 == 0)
printf("2\n");
else if(isprime(n - 2))
printf("2\n");
else
printf("3\n");
}
}