题目地址:http://codeforces.com/contest/735/problem/D
题意:Funt想逃税,税收是他的工资的最大能整除的数,问最少要多少的税钱。
思路:哥德巴赫猜想
如果是质数直接输出1(能整除的除了1就是本身,所以为1)
否则如果是偶数输出2(哥德巴赫猜想,偶数可以由两个质数组成)
否则如果该数-2是质数输出2(因为质数里就2一个偶数,所以特判一下)
否则输出3(哥德巴赫猜想,所有数都能由3个质数组成)
哥德巴赫猜想:百度百科链接
#include <iostream>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdio>
#include <algorithm>
#define LL long long
#define N 100010
#define M 50010
#define inf 0x3f3f3f3f
using namespace std;
const LL mod = 1e9 + 7;
const double eps = 1e-9;
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 (cin >> n) {
if (isprime(n)) {
cout << 1 << endl;
}
else if (n % 2 == 0) {
cout << 2 << endl;
}
else if (isprime(n - 2)) {
cout << 2 << endl;
}
else {
cout << 3 << endl;
}
}
return 0;
}