[CF735D]Taxes
题目大意:给你$n$,把它分成若干个数$n_i$,记价值为$\sum_{i=1}^k(\sum_{j|n_i}j-n_i)$(即分成的每个数的约数和(不包括自身))。(以前写的题,不知道为什么没交)
题解:分成质数,根据哥德巴赫猜想,大于$2$的偶数都可以分成两个质数的和,那么奇数有$3$中可能:$1.$自己是质数;$2.$分成$2$和一个质数;$3.$分成一个质数和一个偶数(再分成两个质数)
卡点:无
C++ Code:
#include <cstdio>
#include <cstdlib>
#include <cmath>
inline bool check(int x) {
int t = sqrt(x);
for (int i = 2; i <= t; i++) if (x % i == 0) return false;
return true;
}
inline void Halt(int x) {
printf("%d\n", x);
exit(0);
}
int n;
int main() {
scanf("%d", &n);
if (check(n)) Halt(1);
if (n & 1) {
if (check(n - 2)) Halt(2);
else Halt(3);
} else Halt(2);
return 0;
}
[CF735D]Taxes的更多相关文章
- CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想
http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...
- [CF45G]Prime Problem
题目大意:将$1$到$n(1<n\leqslant6000)$分成若干组数,要求每组数的和均为质数,若存在一种分配方式,输出每个数所在的组的编号,有多组解输出任意一组解,若不存在,输出$-1$ ...
- code forces 382 D Taxes(数论--哥德巴赫猜想)
Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
- 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 ...
- Taxes
Taxes can be one of the largest cash outflows that a firm experiences.The size of the tax bill(税单) i ...
- The finnacial statements,taxes and cash flow
This chapter-2 we learn about the the financial statements(财务报表),taxes and cash flow.We must pay par ...
- 经典面试题SALES TAXES思路分析和源码分享
题目: SALES TAXES Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and ...
- 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 ...
随机推荐
- Java中的文件和stream流的操作代码
1.Java中FileRead方法的运用代码及详解 package example2;import java.io.FileReader;import java.io.IOException;clas ...
- sftp上传到远程服务器
开发遇到一个需求,需要将图片通过sftp上传到远程服务器上,之前没用过这个功能,折腾了我好几天才搞定,下面记录下我的处理方法: $sftp = 'ssh2.sftp://';//连接sftp $con ...
- Yaf学习(一)----Linux安装Yaf
1.简介 Yaf,全称 Yet Another Framework,是一个高性能的PHP开发框架,采用PHP扩展实现(c语言).Blablablabla....... 2.环境 2.1 虚拟机 虚拟机 ...
- mysql导出数据库表名与字段信息
一.导出数据库表格信息 #mysql导出库的表格信息 SELECT A.TABLE_SCHEMA, A.TABLE_NAME, A.TABLE_ROWS, A.CREATE_TIME, A.TABLE ...
- Hadoop学习(四) FileSystem Shell命令详解
FileSystem Shell中大多数命令都和unix命令相同,只是两者之间的解释不同,如果你对unix命令有基本的了解,那么对于FileSystem Shell的命令,你将会感到很亲切. appe ...
- SQL Server 2005 导出包含(insert into)数据的SQL脚本 (使用存储过程) 分类: 数据库
CREATE PROCEDURE dbo.UspOutputData @tablename sysname AS ) ) ) declare @xtype tinyint declare @name ...
- VM打开虚拟机文件报错
用VM打开以前的虚拟机文件报错 Cannot open the disk 'F:/****.vmdk' or one of the snapshot disks it depends on. 这种问题 ...
- OSI七层模型加协议
OSI七层网络模型 TCP/IP四层概念模型 对应网络协议 应用层(Application) 应用层 HTTP.TFTP, FTP, NFS, WAIS.SMTP 表示层(Presentation) ...
- ACE_Select_Reactor_T 介绍 (2)
本章目录 ACE_Select_Reactor_T 介绍 类继承图 类协作图 类主要成员变量 事件处理函数调用图 事件处理主流程 handle_events 函数流程 handle_events_i ...
- 2.Linux文件和目录
1. 目录和路径 linux下比较特殊的目录: . 代表此层目录 .. 代表上一层目录 - 代表前一个工作目录 ~ 代表『目前使用者身份』所在的home目录 ~account 代表 account 这 ...