题意:已知n元需缴税为n的最大因子x元。现通过将n元分成k份的方式来减少缴税。问通过这种处理方式需缴纳的税费。

分析:

1、若n为素数,不需分解,可得1

2、若n为偶数,由哥德巴赫猜想:一个大于2的偶数可以分解成两个素数的和,可得2

3、若n为奇数,n-2为素数,则为2,否则为3。(因为若为奇数要拆,不能拆成1+偶数,至少拆为2+奇数,若此奇数为素数,则输出为2,否则继续拆成3+偶数,那么结果为3(充分利用哥德巴赫猜想的结论))

#pragma comment(linker, "/STACK:102400000, 102400000")
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
typedef long long ll;
typedef unsigned long long llu;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {, , -, };
const int dc[] = {-, , , };
const int MOD = 1e9 + ;
const double pi = acos(-1.0);
const double eps = 1e-;
const int MAXN = + ;
const int MAXT = + ;
using namespace std;
bool judge_prime(int n){
for(int i = ; i <= sqrt(n + 0.5); ++i){
if(n % i == ){
return false;
}
}
return true;
}
int main(){
int n;
while(scanf("%d", &n) == ){
if(judge_prime(n)){
printf("1\n");
continue;
}
if(n % == ){
printf("2\n");
continue;
}
if(n & ){
if(judge_prime(n - )){
printf("2\n");
continue;
}
else{
printf("3\n");
continue;
}
}
}
return ;
}

Codeforces735D 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. CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想

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

  3. Codefroces 735D Taxes(哥德巴赫猜想)

    题目链接:http://codeforces.com/problemset/problem/735/D 题目大意:给一个n,n可以被分解成n1+n2+n3+....nk(1=<k<=n). ...

  4. D. Taxes 哥德巴赫猜想

    http://codeforces.com/contest/735/problem/D 这题其实我还不是很懂,那个只是猜想,然而却用了. 只想说说找到第一小于n的素数这种思路是不行的. 121 = 1 ...

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

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

  6. CodeForces - 735D Taxes (哥德巴赫猜想)

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

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

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

  8. *CF2.D(哥德巴赫猜想)

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

  9. Codeforces735D Taxes 2016-12-13 12:14 56人阅读 评论(0) 收藏

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

随机推荐

  1. C/C++ - CallBack

    这是实验楼上一个callback debug例子,我没有提交结果,但在本地上运行没有任何问题,也无警告: #include <stdio.h> #define MAX 3 typedef ...

  2. iframe结构的网站按F5刷新子页面的实现方式

    有的网站或者后台系统由于页面有公共的部分,比如菜单,会把公共的部分放在一个页面,这里称之为父页面,而把具体的内容放入一个iframe中,之后的请求改变iframe的内容.但是这样会有一个问题,因为浏览 ...

  3. 5.使用Redis+Flask维护动态Cookies池

    1.为什么要用Cookies池? 网站需要登录才可爬取,例如新浪微博 爬取过程中如果频率过高会导致封号 需要维护多个账号的Cookies池实现大规模爬取 2.Cookies池的要求 自动登录更新 定时 ...

  4. crontab Yii commands 使用方法

    基本知识介绍 #crontab -u <-l, -r, -e> -u指定一个用户-l列出某个用户的任务计划-r删除某个用户的任务-e编辑某个用户的任务 cron文件语法与写法 Minute ...

  5. [Write-up]BSides-Vancouver

    关于 下载链接 目标:拿到root用户目录下的flag.txt 全程无图! 信息收集 因为虚拟机网络是设置Host-only,所以是vmnet1这张网卡,IP段为192.168.7.1/24 nmap ...

  6. 二十 Spring的事务管理及其API&事务的传播行为,编程式&声明式(xml式&注解式,底层AOP),转账案例

    Spring提供两种事务方式:编程式和声明式(重点) 前者需要手写代码,后者通过配置实现. 事务的回顾: 事务:逻辑上的一组操作,组成这组事务的各个单元,要么全部成功,要么全部失败 事务的特性:ACI ...

  7. java并发初探ConcurrentHashMap

    java并发初探ConcurrentHashMap Doug Lea在java并发上创造了不可磨灭的功劳,ConcurrentHashMap体现这位大师的非凡能力. 1.8中ConcurrentHas ...

  8. Linux CentOS7 VMware 相对和绝对路径、cd命令、mkdir/rmdir、rm命令——笔记

    一. 相对和绝对路径 绝对路径是从/(也被称为根目录)开始的,比如/usr.cd /root/ pwd 注:判断用户当前所处的位置 相对路径是以 . 或 .. 开始的 二.cd命令 cd 是进入到当前 ...

  9. L1和L2范数理解

    参考:https://www.jianshu.com/p/4bad38fe07e6

  10. Python递归函数如何写?正确的Python递归函数用法!

    在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数.一.举个例子,我们来计算阶乘n! = 1 x 2 x 3 x … x n,用函数fact(n)表示,可以看出:fac ...