codeforces736b Taxes (Codeforces Round #382 (Div. 1))
题意:纳税额为金额的最大因数(除了本身)。为了逃税将金额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))的更多相关文章
- 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 ...
- Codeforces Round #382 (Div. 2) D. Taxes 歌德巴赫猜想
题目链接:Taxes D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 2017年浙工大迎新赛热身赛 J Forever97与寄信 【数论/素数/Codeforces Round #382 (Div. 2) D. Taxes】
时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言262144K64bit IO Format: %lld 题目描述 Forever97与未央是一对笔友,他们经常互 ...
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- Codeforces Round #382 (Div. 2) 继续python作死 含树形DP
A - Ostap and Grasshopper zz题能不能跳到 每次只能跳K步 不能跳到# 问能不能T-G 随便跳跳就可以了 第一次居然跳越界0.0 傻子哦 WA1 n,k = map ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
- Codeforces Round #382 (Div. 2)B. Urbanization 贪心
B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a l ...
- Codeforces Round #382 (Div. 2) (模拟|数学)
题目链接: A:Ostap and Grasshopper B:Urbanization C:Tennis Championship D:Taxes 分析:这场第一二题模拟,三四题数学题 A. 直接模 ...
- Codeforces Round #382(div 2)
A.= = B. 题意:给出n个数和n1和n2,从n个数中分别选出n1,n2个数来,得到n1个数和n2个数的平均值,求这两个平均值的最大和 分析:排个序从后面抽,注意先从末尾抽个数小的,再抽个数大的 ...
随机推荐
- C# asp:FileUpload上传文件使用JS实现预览效果
js代码: <script type="text/javascript"> //下面用于图片上传预览功能 function setImagePreview() { va ...
- Python3 tkinter基础 Entry validate validatecommand 失去焦点时,检查输入内容
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Cmder + Babun 打造 Windows 好用的终端工具
Babun a windows shell you will love Babun features the following: Pre-configured Cygwin with a lot o ...
- Lazarus分体式改成一体式窗口
安装包 anchordocking和Sparta_DockedFormEditor 然后点选保存并重新编译IDE即可
- javbus爬虫-老司机你值得拥有
# 起因 有个朋友叫我帮忙写个爬虫,爬取javbus5上面所有的详情页链接,也就是所有的https://www.javbus5.com/SRS-055这种链接, 我一看,嘿呀,这是司机的活儿啊,我绝对 ...
- R class of subset of matrix and data.frame
a = matrix( c(2, 4, 3, 1, 5, 7), # the data elements nrow=2, # number of rows ...
- P4246 [SHOI2008]堵塞的交通
思路 同LOJ121 动态图连通性的板子 好像有很神的线段树做法,不会,先码住 代码 #include <cstdio> #include <algorithm> #inclu ...
- P1948 [USACO08JAN]电话线Telephone Lines(二分答案+最短路)
思路 考虑题目要求求出最小的第k+1大的边权,想到二分答案 然后二分第k+1大的边权wx 把所有边权<=wx的边权变为0,边权>wx的边权变为0,找出最短路之后,如果dis[T]<= ...
- (zhuan) Attention in Long Short-Term Memory Recurrent Neural Networks
Attention in Long Short-Term Memory Recurrent Neural Networks by Jason Brownlee on June 30, 2017 in ...
- Linux---centos 配置网络
Linux配置网络,有两种方式,一种是通过图像化的界面来配置网络IP,另一种方式是通过命令行来配置IP 1.第一种方式通过图形化的界面来配置IP 1.0修改之前的IP地址 1.1点击图片中的那个 网络 ...