题目链接:Taxes
D. Taxes
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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

Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal way to split n 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
题意:一个n可以拆成任意多个数,每个数都不为1,f(n)=最大的因子(除了其本身);使得拆的和最小;
思路:显然拆成素数会使得解更优,相当于问最少拆成几个素数;根据歌德巴赫猜想;详见代码;

传送门:歌德巴赫猜想

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define esp 0.00000000001
const int N=1e5+,M=1e6+,inf=1e9;
const ll INF=1e18+;
int prime(int n)
{
if(n<=)
return ;
if(n==)
return ;
if(n%==)
return ;
int k, upperBound=n/;
for(k=; k<=upperBound; k+=)
{
upperBound=n/k;
if(n%k==)
return ;
}
return ;
}
int main()
{
int x;
scanf("%d",&x);
if(prime(x))
return puts("");
if(x%==)
return puts("");
if(prime(x-))
return puts("");
puts("");
return ;
}

Codeforces Round #382 (Div. 2) D. Taxes 歌德巴赫猜想的更多相关文章

  1. Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想

    D. Taxes 题目链接 http://codeforces.com/contest/735/problem/D 题面 Mr. Funt now lives in a country with a ...

  2. 2017年浙工大迎新赛热身赛 J Forever97与寄信 【数论/素数/Codeforces Round #382 (Div. 2) D. Taxes】

    时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld 题目描述 Forever97与未央是一对笔友,他们经常互 ...

  3. codeforces736b Taxes (Codeforces Round #382 (Div. 1))

    题意:纳税额为金额的最大因数(除了本身).为了逃税将金额n分为n1+n2+.......问怎样分纳税最少. 哥德巴赫猜想: 任一大于2的偶数都可写成两个质数之和. 质数情况: 任何大于5的奇数都是三个 ...

  4. Codeforces Round #382 Div. 2【数论】

    C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...

  5. Codeforces Round #382 (Div. 2) 继续python作死 含树形DP

    A - Ostap and Grasshopper zz题能不能跳到  每次只能跳K步 不能跳到# 问能不能T-G  随便跳跳就可以了  第一次居然跳越界0.0  傻子哦  WA1 n,k = map ...

  6. Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划

    C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...

  7. Codeforces Round #382 (Div. 2)B. Urbanization 贪心

    B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a l ...

  8. Codeforces Round #382 (Div. 2) (模拟|数学)

    题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...

  9. Codeforces Round #382(div 2)

    A.= = B. 题意:给出n个数和n1和n2,从n个数中分别选出n1,n2个数来,得到n1个数和n2个数的平均值,求这两个平均值的最大和 分析:排个序从后面抽,注意先从末尾抽个数小的,再抽个数大的 ...

随机推荐

  1. linux端口

    1.查看开放的端口 netstat -anp 来查看哪些端口被打开. 注:加参数'-n'会将应用程序转为端口显示,即数字格式的地址,如:nfs->2049, ftp->21,因此可以开启两 ...

  2. php版redis插件,SSDB数据库,增强型的Redis管理api实例

    php版redis插件,SSDB数据库,增强型的Redis管理api实例 SSDB是一套基于LevelDB存储引擎的非关系型数据库(NOSQL),可用于取代Redis,更适合海量数据的存储.另外,ro ...

  3. Hibernate,JPA注解@EmbeddedId

    定义组合主键的几种语法: 将组件类注解为@Embeddable,并将组件的属性注解为@Id 将组件的属性注解为@EmbeddedId 将类注解为@IdClass,并将该实体中所有属于主键的属性都注解为 ...

  4. Python基础第一篇

    一.第一句python代码 1.python执行过程:1.加载内存-词法分析-语法分析-编译-执行 2.创建hello.py文件,输入内容 #!/usr/bin/env python print &q ...

  5. two day python基础知识

    1.调用功能 ---- -在同一个目录下,调用用户名密码登陆模块 2.创建文件夹 import os #os模块 os.mkdir ("new_dd3")# 创建文件夹 三元 3. ...

  6. ubuntu-E:Encountered a section with no Package: header的解决办法

    刚才打开ubuntu,我的版本是12.04.正想使用sudo apt-get install build-essential 时,出现了如下错误: E:Encountered a section wi ...

  7. css3 简单动画

    <script> <!-- var x,y,n=0,ny=0,rotINT,rotYINT function rotateDIV() { x=document.getElementB ...

  8. Pipe(点积叉积的应用POJ1039)

    Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9723   Accepted: 2964 Description ...

  9. HDU(2255),KM算法,最大权匹配

    题目链接 奔小康赚大钱 Time Limit: 1000/1000MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  10. masonry插件和infinitescroll插件实现无刷新无分页完美瀑布流

    地址有:http://www.17sucai.com/pins/2657.html 如果你善于发现美,如果你善于观察新鲜的事物,如果你是一名有爱的前端攻城师或设计尸,那么你一定不会对下面图片中的结构感 ...