[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 ...
随机推荐
- maven-坐标与依赖
1.坐标-找到项目依赖的重要依据 <groupId>cmbc.com.cn</groupId> <artifactId>myapp</artifactId&g ...
- 【tp5.1】微信公众号授权登录及获取信息录入数据库
微信公众号开发文档链接:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1445241432 微信公众号授权登录分为两种: 1.以 ...
- Yii 2.0.6 - 从入口到Action执行
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); r ...
- spark-day1
#!/usr/bin/python # -*- coding: utf_8 -*- from pyspark import SparkConf, SparkContext import os, tim ...
- Scrapy之Cookie和代理
cookie cookie: 获取百度翻译某个词条的结果 一定要对start_requests方法进行重写. 两种解决方案: 1. Request()方法中给method属性赋值成post2. For ...
- 2018 ccpc final I. Cockroaches
I. Cockroaches time limit per test6. s memory limit per test256 MB inputstandard input outputstandar ...
- 『Python Kivy』官方乒乓球游戏示例解析
本篇文章用于对Kivy框架官方所给出的一个「乒乓球」小游戏的源码进行简单地解析.我会尽可能的将方方面面的内容都说清楚.在文章的最下方为官方所给出的这个小游戏的教程以及游戏源码. 由于篇幅所限,本文只简 ...
- Qt HUD(平显)演示程序绿色版
把一个黑底白字的程序改成黑底绿字 上对比图,左侧是原本,右侧是仿造,有些地方比例还是有问题 其实这个程序没有啥技术含量,就是画 #include "mainwindow.h" #i ...
- Qt QLabel 播放GIF动画
很久以前用过,不过慢慢的不用了,就慢慢的忘记了,今天拾起来,记录一下,以后用的时候可以翻一下 QLabel播放GIF动画其实很简单 第一步,需要包含头文件,Qt播放GIF动画,我使用的是QMovie类 ...
- bugku 字符正则
字符?正则? <?php highlight_file('2.php'); $key='KEY{********************************}'; $IM= preg_mat ...