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元钱,n>1,要缴纳n的最大质因数的税,但可以把n分成若干份缴纳每一份最大质因数的和,其中不能有1。
代码:
 //哥德巴赫猜想:任意一个大于2的偶数可以拆成两个素数的和,任意一个大于7的奇数可以拆成三个素数的和。
//本题答案是1.判断n是否是素数。是2.判断是否是偶数;猜想的逆就是除了2以外任意两个素数的和都是偶数所以还要判断n-2是不是素数。否则就是三3。
#include<bits\stdc++.h>
using namespace std;
int sus(int n)
{
int tem=sqrt(n);
for(int i=;i<=tem;i++)
if(n%i==) return ;
return ;
}
int main()
{
int n;
scanf("%d",&n);
if(sus(n))
printf("1\n");
else if(n%==||sus(n-))
printf("2\n");
else printf("3\n");
return ;
}

*CF2.D(哥德巴赫猜想)的更多相关文章

  1. C#实现哥德巴赫猜想

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Goet ...

  2. code forces 382 D Taxes(数论--哥德巴赫猜想)

    Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...

  3. CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想

    http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...

  4. 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 ...

  5. Codeforces 735D:Taxes(哥德巴赫猜想)

    http://codeforces.com/problemset/problem/735/D 题意:给出一个n,这个n可以分解成 n = n1 + n2 + -- + nk,其中k可以取任意数.要使得 ...

  6. LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)

    http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...

  7. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  8. 哥德巴赫猜想证明(C语言实现50以内的正偶数证明)

    <一>哥德巴赫猜想内容: 一个充分大的偶数(大于或等于6)可以分解为两个素数之和. <二>实现要点: 要点: 判断素数(质数):除了1和本身没有其他约数. 最小的质数:2 判断 ...

  9. c语言验证哥德巴赫猜想(从4开始 一个偶数由两个质数之和)

    #include <stdio.h> #include <stdlib.h> #include <math.h> int isit(int num) { int i ...

随机推荐

  1. URAL 1827 Indigenous Wars(排序、乱搞)

    题意:给一个长度为n数组{a[i]}.有m个操作Ti,Si,Li表示找以Ti值结束,以Si值开始,长度为Li的连续子串.找到后,将区间的答案值设为1.一开始答案值全部为0.最后输出n个答案值. 好久没 ...

  2. studing(来自转载)

    1.getchar(): http://www.cnblogs.com/jiangjun/archive/2012/05/16/2503676.html 2.gets()和scanf( ): http ...

  3. java内存溢出和内存泄露

    虽然jvm可以通过GC自动回收无用的内存,但是代码不好的话仍然存在内存溢出的风险. 最近在网上搜集了一些资料,现整理如下: —————————————————————————————————————— ...

  4. mysql 事件

    经常要周期性的执行某一个命令或者SQL语句.mysql事件,mysql的版本是5.1以上. 首先要查看事件是否开启了, SHOW VARIABLES LIKE 'event_scheduler'; S ...

  5. python之路:Day04 --- Python基础4

    本节内容 1.字符串格式化 2.迭代器和生成器 3.装饰器 4.Json & pickle 数据序列化 5.软件目录结构规范 一.字符串格式化 百分号式 %[(name)][flags][wi ...

  6. 《Mastering.Ext.JS. 》书上主要示例都搞了个样子出来,纪念

  7. POCO库——Foundation组件之加解密Crypt

    加解密Crypt:内部提供多种加解密方式.信息摘要提取.随机数产生等,具体的算法内部实现不做研究学习: DigestEngine.h :DigestEngine类作为各种摘要提取的基类,提供必要的接口 ...

  8. TFS Express backup and restore

    When we setup source control server, we should always make a backup and restore plan for it. This ar ...

  9. vim简明教程

    在shell中新建一个文件 # vim a.txt vim有三种模式:一般模式.插入模式.底行模式 三种工作模式 1.命令模式 移动光标 hjkl yy 复制 nyy 从光标向下复制n行 0 移动光标 ...

  10. Servlet

    建议:对于javaEE,在如何学习jsp和servlet时,初学者往往是一头雾水.我当时就被jsp的各种标签.内置对象和servlet整的很惨.所以,学习方法变得特别特别重要:而且,随着技术的更新和发 ...