Splits CodeForces - 964A
题意:
我们定义一个不上升的且和为 n 的正整数序列,叫做 n 的分解.
比如, 下面是8的分解: [4, 4], [3, 3, 2], [2, 2, 1, 1, 1, 1], [5, 2, 1].
而这些则不是8的分解: [1, 7], [5, 4], [11, -3], [1, 1, 4, 1, 1].
一个分解的权值等于第一个数的个数. 例如, [1, 1, 1, 1, 1] 的权值是 5, [5, 5, 3, 3, 3] 的权值是 2, [9] 的权值是 1.
给定一个 n, 找到不同权值的分解的个数.
Input
第一行输入一个整数 n (1 <= n <= 10^9).
Output
输出一个整数 — 即上述问题的答案.
Examples
7
4
8
5
9
5
Note
第一组样例,下面是可能的 7的分解的权值:
权值为 1: [7]
权值为 2: [3, 3, 1]
权值为 3: [2, 2, 2, 1]
权值为 7: [1, 1, 1, 1, 1, 1, 1]
题解:
我们只需要输出n/2+1就行了,因为n/2就是能得到的最大权值 (除去n/1),那么比n/2小的权值肯定存在,比如(2,2,2,2,1),那么可变成(2,2,2,1,1,1),或者(2,2,1,1,1,1,1)
代码:
1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<queue>
6 #include<map>
7 #include<vector>
8 #include<math.h>
9 #define mem(a,x) memset(a,x,sizeof(a))
10 using namespace std;
11 typedef long long ll;
12 const int maxn=1e5+10;
13 const int mod=26;
14 const int INF=0x3f3f3f3f;
15 const int Times = 10;
16 const int N = 5500;
17 int main()
18 {
19 ll n;
20 while(~scanf("%I64d",&n))
21 {
22 printf("%I64d\n",n/2+1);
23 }
24 return 0;
25 }
Splits CodeForces - 964A的更多相关文章
- 一道有意思的找规律题目 --- CodeForces - 964A
题目连接: https://vjudge.net/problem/1502082/origin 这一题第一眼看过去貌似是模拟,但是根据其范围是1e9可以知道,如果暴力解基本上是不可能的(不排除大佬级优 ...
- CodeForces 176B Word Cut dp
Word Cut 题目连接: http://codeforces.com/problemset/problem/176/C Description Let's consider one interes ...
- CodeForces 176B Word Cut (计数DP)
Word Cut Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit St ...
- Codeforces Round #540 (Div. 3) F1. Tree Cutting (Easy Version) 【DFS】
任意门:http://codeforces.com/contest/1118/problem/F1 F1. Tree Cutting (Easy Version) time limit per tes ...
- 【codeforces 750D】New Year and Fireworks
time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- 【Jboss】一台服务器上如何部署多个jboss
一台服务器上如何部署多个jboss呢?直接把整个部署环境copy一份到相应的目录下? 这样只是前提,但是启动复制后的jboss就会发现,有很多端口被占用 3873,8080,8009,8443,808 ...
- ctfshow—web—web3
打开靶机 提示是文件包含漏洞 测试成功 https://d7c9f3d7-64d2-4110-a14b-74c61f65893c.chall.ctf.show/?url=../../../../../ ...
- ftp交互和控制命令总结
一.FTP管理: 基于tcp,首先有客户端相服务端的知名端口21发起tcp连接建立ftp控制连接,控制连接在整个会话期间都保持打开,只用来发送连接/传送请求. 这里分为两种模式: 主动模式(PORT) ...
- oracle 存储过程和包的权限
GRANT CREATE ANY PROCEDURE TO MONKEY --創建,查看,替換的權限 GRANT EXECUTE ANY PROCEDURE TO MONKEY --執行和查看的權限 ...
- [从源码学设计]蚂蚁金服SOFARegistry之配置信息
[从源码学设计]蚂蚁金服SOFARegistry之配置信息 目录 [从源码学设计]蚂蚁金服SOFARegistry之配置信息 0x00 摘要 0x01 业务范畴 1.1 配置作用 1.2 学习方向 0 ...
- 处理 K8S Orphaned pod found - but volume paths are still present on disk 孤儿pod
问题概述 查看kubelet或/var/log/messages日志一直包错,发现是孤儿pod,是由于其pod被删除后存储路径还保存在磁盘. 报错如下 [root@node5 ~]# journalc ...
- 【Android初级】使用Gallery实现照片拖动的特效(附源码)
今天要分享一个非常简单的功能: 使用Android原生控件Gallery实现照片拖动的特效 实现思路如下: 在布局文件中定义一个Gallery控件 由于要显示多张图,为了方便,我直接引用了Androi ...
- Property or method "previewUrl" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components,
Property or method "previewUrl" is not defined on the instance but referenced during rende ...
- MySQL调优性能监控之show profile
用show profile查询工具指定具体的type show profile在mysql5.7之后过时 show profile命令用于跟踪执行过的sql语句的资源消耗信息,可以帮助查看sql语句的 ...
- ArchLinux安装后所需要的环境和工具
ArchLinux安装后所需要的环境和工具 工具: Dolphin 文件管理器 ntfs-3G 移动硬盘挂载 octopi 实时检查更新 KDE Connect 手机电脑远程连接 DBeaver Co ...