哥德巴赫猜想CodeForce382Div2 D
来源:互联网 发布:淘宝店铺交易平台 编辑:程序博客网 时间:2024/05/17 00:02
哥德巴赫猜想
(世界近代三大数学难题之一)
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.
The first line of the input contains a single integer n (2 ≤ n ≤ 2·109) — the total year income of mr. Funt.
Print one integer — minimum possible number of burles that mr. Funt has to pay as a tax.
#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;
}
- 哥德巴赫猜想CodeForce382Div2 D
- codeforce 382 D. Taxes(哥德巴赫猜想)
- codeforces 735D Taxes 哥德巴赫猜想
- codeforces 735D Taxes 哥德巴赫猜想
- code forces 735D 数论(哥德巴赫猜想)
- Codeforces 735 D Taxes (哥德巴赫猜想)
- codeforces 584D(哥德巴赫猜想)
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想。
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- 哥德巴赫猜想
- RAM和 flash这个东西
- MPI求素数个数
- 俄罗斯乘法
- 让渡价值
- 阿里面试题
- 哥德巴赫猜想CodeForce382Div2 D
- 17年苹果强推ATS,看了好多免费证书。。。
- Android 不停旋转图片
- MySQL 笔记
- CSS基础知识点轨迹(二)
- Python3.x和Python2.x的区别
- 串口的中断和接收
- 单链表的操作
- JNI常用函数说明二