题意:

我们定义一个不上升的且和为 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

Input
7
Output
4
Input
8
Output
5
Input
9
Output
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的更多相关文章

  1. 一道有意思的找规律题目 --- CodeForces - 964A

    题目连接: https://vjudge.net/problem/1502082/origin 这一题第一眼看过去貌似是模拟,但是根据其范围是1e9可以知道,如果暴力解基本上是不可能的(不排除大佬级优 ...

  2. CodeForces 176B Word Cut dp

    Word Cut 题目连接: http://codeforces.com/problemset/problem/176/C Description Let's consider one interes ...

  3. CodeForces 176B Word Cut (计数DP)

    Word Cut Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit St ...

  4. 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 ...

  5. 【codeforces 750D】New Year and Fireworks

    time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. Linux tar压缩和解压

    经常会忘记 tar 压缩和解压命令的使用,故记下来. 1. 打包压缩 tar -zcvf pack.tar.gz pack/ #打包压缩为一个.gz格式的压缩包 tar -jcvf pack.tar. ...

  2. 系统吞吐量与QPS/TPS

    QPS/TPS QPS:Queries Per Second意思是"每秒查询率",是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准. ...

  3. 【Problems】:JSON parse error: Invalid UTF-8 start byte 0xbd;

    简单记录一下 ,我本地开发环境这样写测试时没有问题, @ApiOperation(value="取消关注") @PostMapping("cancelFollow&quo ...

  4. 攻防世界 - Crypto(一)

    base64: 根据题目base64可知编码方式,下载附件发现是一个txt文件,把内容用工具解码就彳亍了,即可得到flag, flag: cyberpeace{Welcome_to_new_World ...

  5. Vulnhub靶场——DC-1

    记一次Vulnhub靶场练习记录 靶机DC-1下载地址: 官方地址 https://download.vulnhub.com/dc/DC-1.zip 该靶场共有5个flag,下面我们一个一个寻找 打开 ...

  6. SAP中的密码输入框

    在SAP中的密码输入框,可分为两种情况: 1.用selection语句书写的选择屏幕上的密码输入框 实现的方式就是在AT SELECTION-SCREEN OUTPUT事件中写入如下代码: LOOP ...

  7. SAP 中session和外部断点设置的区别

    1 Session Breakpoints:只在当前user session的所有main session中有效 2 External Breakpoints 在abap editor或事务SICF中 ...

  8. 【Azure 应用服务】App Service中,为Java应用配置自定义错误页面,禁用DELETE, PUT方法

    问题定义 使用Azure应用服务(App Service),部署Java应用,使用Tomcat容器,如何自定义错误页面呢?同时禁用DELETE, PUT方法 解决办法 如何自定义错误页面呢?需要在 J ...

  9. 有状态(Stateful)应用的容器化 - 云+社区 - 腾讯云 https://cloud.tencent.com/developer/article/1020178

    有状态(Stateful)应用的容器化 - 云+社区 - 腾讯云 https://cloud.tencent.com/developer/article/1020178

  10. 回归测试_百度百科 https://baike.baidu.com/item/%E5%9B%9E%E5%BD%92%E6%B5%8B%E8%AF%95

    回归测试_百度百科https://baike.baidu.com/item/%E5%9B%9E%E5%BD%92%E6%B5%8B%E8%AF%95