Codeforces735D Taxes(哥德巴赫猜想)
题意:已知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(哥德巴赫猜想)的更多相关文章
- 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 ...
- CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想
http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...
- Codefroces 735D Taxes(哥德巴赫猜想)
题目链接:http://codeforces.com/problemset/problem/735/D 题目大意:给一个n,n可以被分解成n1+n2+n3+....nk(1=<k<=n). ...
- D. Taxes 哥德巴赫猜想
http://codeforces.com/contest/735/problem/D 这题其实我还不是很懂,那个只是猜想,然而却用了. 只想说说找到第一小于n的素数这种思路是不行的. 121 = 1 ...
- code forces 382 D Taxes(数论--哥德巴赫猜想)
Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
- CodeForces - 735D Taxes (哥德巴赫猜想)
Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
- Codeforces 735D:Taxes(哥德巴赫猜想)
http://codeforces.com/problemset/problem/735/D 题意:给出一个n,这个n可以分解成 n = n1 + n2 + -- + nk,其中k可以取任意数.要使得 ...
- *CF2.D(哥德巴赫猜想)
D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
- 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 ...
随机推荐
- 常见Linux发行版有哪些?
Linux 发行版(英语:Linux distribution,也被叫做GNU/Linux 发行版),为一般用户预先集成好的Linux操作系统及各种应用软件.一般用户不需要重新编译,在直接安装之后,只 ...
- nacos作为配置中心动态刷新@RefreshScope添加后取值为null的一个问题
之前springboot项目常量类如下形式: @Component @RefreshScope//nacos配置中心时添加上 public class Constants { @Value(" ...
- 树莓派4B踩坑指南 - (5)设置阿里云的源及解决apt提示依赖
解决树莓派apt升级/安装提示依赖问题: 注意!!buster是根据系统版本(cat /etc/os-release)来写的,如果是jessie或者stretch要改为buster.参考解决树莓派ap ...
- One-Hot Encoding(独热编码)
前几天查了一些与独热编码相关的资料后,发现看不进去...看不太懂,今天又查了一下,然后写了写代码,通过自己写例子加上别人的解释后,从结果上观察,明白了sklearn中独热编码做了什么事. 下面举个例子 ...
- partition_show , a new version to check partition table status in sqlserver
Dear all: I had put "partition_show" before . but this time it makes faster. partition_sho ...
- Django 学习 之 视图层(views)
一个视图函数,简称视图,是一个简单的Python 函数,它接受Web请求并且返回Web响应.响应可以是一张网页的HTML内容,一个重定向,一个404错误,一个XML文档,或者一张图片. . . 是任何 ...
- 笔记||Pyhthon3进阶之多线程操作共享数据
# 多线程操作共享数据--------------------------------------------------------------- # import threading# 使用锁# ...
- 中山普及Day13——普及
又是迷之自信的说...估的230,考的50整,我欲上天呐!!! T1:深渊(怕不是黑暗种族聚集地???) 思路:动归.而且是简单动归.转移方程:Fi,j=max(Fi-1,j,Fi,j,Fi-1,(j ...
- 基于金山快盘的Git服务器、快盘+ Git GUI 实现代码版本管理
Git,这货堪称神器,用了它就再也不想用其他VCS了,就像上了高速就不想再走国道一样. Git的强大之处在于,你可以在局域网内的任何一个共享路径下创建仓库,而不需要运行任何服务.所有的操作都是 ...
- mysql判断数据库或表是否存在
(1) 判断数据库存在, 则删除: drop database if exists db_name;(2) 判断数据表存在, 则删除: drop table if exists table ...