题意:纳税额为金额的最大因数(除了本身)。为了逃税将金额n分为n1+n2+......。问怎样分纳税最少。

哥德巴赫猜想:

任一大于2的偶数都可写成两个质数之和。

质数情况:

任何大于5的奇数都是三个素数之和

因此,如果n是偶数,结果就是2。

如果n是奇数。奇数只能拆成一奇一偶。分为2种情况。一偶是2时,那么如果一奇是质数,结果为2。如果一奇不是质数,那么结果至少为3,由于哥德巴赫猜想,3一定可行的,因此结果就是3。

一偶不是2时,一偶至少要交税2,一奇至少交税1,同样由猜想,结果为3。

//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
#include <list>
using namespace std;
const int SZ=,INF=0x7FFFFFFF;
typedef long long lon; bool isprime(lon x)
{
int sq=sqrt(x);
for(int i=;i<=sq;++i)
{
if(x%i==)return ;
}
return ;
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon n;
cin>>n;
if(isprime(n))
{
cout<<<<endl;
}
else if((n&)==)
{
cout<<<<endl;
}
else
{
if(isprime(n-))
{
cout<<<<endl;
}
else cout<<<<endl;
}
return ;
}

codeforces736b Taxes (Codeforces Round #382 (Div. 1))的更多相关文章

  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. Codeforces Round #382 (Div. 2) D. Taxes 歌德巴赫猜想

    题目链接:Taxes D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

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

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

  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. 比较实用的前端 js框架 ,组件 汇总

    一.js 前端ui框架 Kendo UI 商用收费,组件丰富,界面简洁美观,有jQuery和angular两个js的版本 Webix 商用收费,组件丰富,界面特别美观 JQwidgets 商用收费,丰 ...

  2. XXXcannot be resolved to a type

    编写自动化测试用例一个新创建的用例中类继承了其他类,由于未知原因,eclipse没能自动编译源代码到build/classes(或其他classes目录)代码一直报错XXX cannot be res ...

  3. Bootstrap3基础 nav 便签页(横版、竖版)

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  4. Bootstrap3基础 img-responsive 响应式图片

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  5. Java TreeSet的定制排序

    注:只贴出实现类 package Test3; import java.util.Comparator;import java.util.TreeSet; public class Test { pu ...

  6. Google advertiser api开发概述——部分失败

    部分失败 某些 AdWords 服务允许您请求执行有效操作,而对失败的操作返回错误.此功能(称为部分失败)允许您在结束时单独处理失败的操作. 技术细节 要使用此功能,您需要设置此可选的 SOAP 标头 ...

  7. 17秋 SDN课程 第一次作业

    SDN第一次作业 你会选择作 网络编程 方向的程序员吗?为什么? 有可能.原因如下: 1.我的研究与网络密切相关: 2.SDN侧重软件实现,自然涉及socket等网络编程知识,属于基本功: 3.市场. ...

  8. Qt5学习记录:QString与int值互相转换

    1)QString转int 直接调用toInt()函数 例: QString str("100"); int tmp = str.toInt(); 或者: bool ok; QSt ...

  9. linux运行lnmp 出现502错误

    之前遇到的问题: 安装好之后访问域名出现502错误,打开html文件正常,说明是php出现问题.在wwwlog文件夹查看nginx日志,发现报错原因是找不到/var/run/php5-fpm.sock ...

  10. Pandas 基础(2) - Dataframe 基础

    上一节我们已经对 Dataframe 的概念做了一个简单的介绍, 这一节将具体看下它的一些基本用法: 首先, 准备一个 excel 文件, 大致内容如下, 并保存成 .csv 格式. 然后, 在 ju ...