题意:纳税额为金额的最大因数(除了本身)。为了逃税将金额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. rocketmq总结(消息的顺序、重复、事务、消费模式)

    rocketmq总结(消息的顺序.重复.事务.消费模式) 参考: http://www.cnblogs.com/wxd0108/p/6038543.html https://www.cnblogs.c ...

  2. R t-test cor.test

    a = c(175, 168, 168, 190, 156, 181, 182, 175, 174, 179)b = c(185, 169, 173, 173, 188, 186, 175, 174, ...

  3. nohup 让进程在后台可靠运行的几种方法

    1. nohup nohup 无疑是我们首先想到的办法.顾名思义,nohup 的用途就是让提交的命令忽略 hangup 信号. nohup 的使用是十分方便的,只需在要处理的命令前加上 nohup 即 ...

  4. P3810 【模板】三维偏序(陌上花开)(cdq分治)

    思路 看到这种偏序类的题目,而且不要求强制在线,可以立刻想到cdq分治 注意这题有一个问题,就是询问的是小于等于而不是小于,如果相等的话两个元素会相互贡献,而cdq的特点是右区间不能对左边有影响,所以 ...

  5. Tutorial on GoogleNet based image classification --- focus on Inception module and save/load models

    Tutorial on GoogleNet based image classification  2018-06-26 15:50:29 本文旨在通过案例来学习 GoogleNet 及其 Incep ...

  6. computed 计算选项

    computed 的作用主要是对原数据进行改造输出.改造输出:包括格式的编辑,大小写转换,顺序重排,添加符号……. 格式化输出结果 我们先来做个读出价格的例子:我们读书的原始数据是price:100 ...

  7. [bug] - 关于poi导入excel时间格式会减少8小时的问题.

    这个bug发生在使用poi组件导入导出excel时,(这里是导入) 首先在excel中的格式设定是 yyyy-mm-dd hh:mm:ss 通过配套使用ExcelUtil中 getCellValue( ...

  8. NodeJS 获取网页源代码

    获取网页源代码 node 获取网页源代码 var http = require('http'); var url = "http://www.baidu.com/"; // 参数u ...

  9. 理解ffmpeg中的pts,dts,time_base

    首先介绍下概念: PTS:Presentation Time Stamp.PTS主要用于度量解码后的视频帧什么时候被显示出来 DTS:Decode Time Stamp.DTS主要是标识读入内存中的b ...

  10. 为DataGridView增加鼠标滚轮功能

    #region 鼠标滚动 [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "Wi ...