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

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 }

猜你喜欢

转载自www.cnblogs.com/kongbursi-2292702937/p/12678090.html