题意:

我们定义一个不上升的且和为 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学习笔记 | 配置nginx

    目录 一.Nginx概述 二.why Nginx? 三.Linux安装Nginx APT源安装 官网源码安装 四.nginx相关文件的配置 html文件:/var/www/html/index.htm ...

  2. 在项目中应该使用Boolean还是使用boolean?

    起因 在公司看代码时,看到了使用Boolean对象来完成业务逻辑判断的操作.和我的习惯不一致,于是引起了一些反思. boolean和Boolean的差别咱就不说了,我们仅探讨使用boolean与Boo ...

  3. Linux下Too many open files问题排查与解决

    作者: Grey 原文地址: Github 语雀 博客园 Too many open files是Linux系统中常见的错误,从字面意思上看就是说程序打开的文件数过多,不过这里的files不单是文件的 ...

  4. 利用vbs隐藏dos窗口

    方法一: option explicitdim wshshellset wshshell=wscript.createobject("wscript.shell")wshshell ...

  5. jackson学习之一:基本信息

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  6. STL_常用的算法

    STL_常用的算法 一.常用的查找算法 adjacent_find() adjacent_find(iterator beg, iterator end, _callback); 在iterator对 ...

  7. 使用Python的pandas模块、mplfinance模块、matplotlib模块绘制K线图

    目录 pandas模块.mplfinance模块和matplotlib模块介绍 pandas模块 mplfinance模块和matplotlib模块 安装mplfinance模块.pandas模块和m ...

  8. Java并发组件三之Semaphore

    使用场景:常用于使用有限的资源,限制线程并发的最大数量.默认情况下,信号量是非公平性的(先等待先执行为公平.类似于买东西的时候大家排队付款,先来的先付款是公平的.但是这时候有人插队,那就是非公平的)设 ...

  9. Redis 雪崩、穿透和击穿

    https://github.com/doocs/advanced-java/blob/master/docs/high-concurrency/redis-caching-avalanche-and ...

  10. Elasticsearch--ES-Head--docker版安装

    1.0ElasticSearch安装 # 拉取ES镜像docker pull elasticsearch:6.5.0 # 设置vm.max_map_count大小sysctl -w vm.max_ma ...