哥德巴赫猜想CodeForce382Div2 D

来源:互联网 发布:淘宝店铺交易平台 编辑:程序博客网 时间:2024/05/17 00:02

哥德巴赫猜想

(世界近代三大数学难题之一)

哥德巴赫1742年给欧拉的信中哥德巴赫提出了以下猜想:任一大于2的偶数都可写成两个质数之和。但是哥德巴赫自己无法证明它,于是就写信请教赫赫有名的大数学家欧拉帮忙证明,但是一直到死,欧拉也无法证明。因现今数学界已经不使用“1也是素数”这个约定,原初猜想的现代陈述为:任一大于5的整数都可写成三个质数之和。欧拉在回信中也提出另一等价版本,即任一大于2的偶数都可写成两个质数之和。今日常见的猜想陈述为欧拉的版本。把命题"任一充分大的偶数都可以表示成为一个素因子个数不超过a个的数与另一个素因子不超过b个的数之和"记作"a+b"。1966年陈景润证明了"1+2"成立,即"任一充分大的偶数都可以表示成二个素数的和,或是一个素数和一个半素数的和"。
今日常见的猜想陈述为欧拉的版本,即任一大于2的偶数都可写成两个素数之和,亦称为“强哥德巴赫猜想”或“关于偶数的哥德巴赫猜想”。
从关于偶数的哥德巴赫猜想,可推出:任一大于7的奇数都可写成三个质数之和的猜想。后者称为“弱哥德巴赫猜想”或“关于奇数的哥德巴赫猜想”。若关于偶数的哥德巴赫猜想是对的,则关于奇数的哥德巴赫猜想也会是对的。弱哥德巴赫猜想尚未完全解决,但1937年时前苏联数学家维诺格拉多夫已经证明充分大的奇质数都能写成三个质数的和,也称为“哥德巴赫-维诺格拉朵夫定理”或“三素数定理”。

 
D. Taxes
time limit per test
2 seconds
memory limit per test
256 megabytes

Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal ton (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor ofn (not equal to n, of course). For example, ifn = 6 then Funt has to pay 3 burles, while forn = 25 he needs to pay 5 and if n = 2 he pays only1 burle.

As mr. Funt is a very opportunistic person he wants to cheat a bit. In particular, he wants to split the initialn in several parts n1 + n2 + ... + nk = n (herek is arbitrary, even k = 1 is allowed) and pay the taxes for each part separately. He can't make some part equal to1 because it will reveal him. So, the condition ni ≥ 2 should hold for alli from 1 to k.

Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal way to splitn in parts.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 2·109) — the total year income of mr. Funt.

Output

Print one integer — minimum possible number of burles that mr. Funt has to pay as a tax.

Examples
Input
4
Output
2
Input
27
Output
3

#include<stdio.h>
#include<math.h>
bool judge(long long k)
{
    int r = sqrt (k + 1);
    for(int i = 2 ;i <= r ;i++)
    {
        if (k % i == 0)
        return 0;
    }
    return 1;
}
long long n;
int main()
{
    scanf("%lld",&n);
    if(judge(n)||n==2|n==3) printf("1\n");
    else if(n%2==0||judge(n-2)) printf("2\n");
    else printf("3\n");
    return 0;
}
0 0