题意:

我们定义一个不上升的且和为 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
  1. 7
Output
  1. 4
Input
  1. 8
Output
  1. 5
Input
  1. 9
Output
  1. 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. 1 #include<stdio.h>
  2. 2 #include<string.h>
  3. 3 #include<iostream>
  4. 4 #include<algorithm>
  5. 5 #include<queue>
  6. 6 #include<map>
  7. 7 #include<vector>
  8. 8 #include<math.h>
  9. 9 #define mem(a,x) memset(a,x,sizeof(a))
  10. 10 using namespace std;
  11. 11 typedef long long ll;
  12. 12 const int maxn=1e5+10;
  13. 13 const int mod=26;
  14. 14 const int INF=0x3f3f3f3f;
  15. 15 const int Times = 10;
  16. 16 const int N = 5500;
  17. 17 int main()
  18. 18 {
  19. 19 ll n;
  20. 20 while(~scanf("%I64d",&n))
  21. 21 {
  22. 22 printf("%I64d\n",n/2+1);
  23. 23 }
  24. 24 return 0;
  25. 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. 深入理解nodejs中的异步编程

    目录 简介 同步异步和阻塞非阻塞 javascript中的回调 回调函数的错误处理 回调地狱 ES6中的Promise 什么是Promise Promise的特点 Promise的优点 Promise ...

  2. python学习笔记 | 顺序表的常规操作

    ''' @author: 人人都爱小雀斑 @time: 2020/3/11 8:46 @desc: 顺序表的相关操作 ''' class SequenceList: def __init__(self ...

  3. DOS的FOR命令用法总结

    鉴于dos自带的关于for命令的帮助信息看起来太简单,自己总结了一下,并增加了必要的实例,以备日后自己查阅.其中一些地方可能存在理解错误,敬请指出. [转发请注明出处]

  4. JS实现鼠标移入DIV随机变换颜色

    今天分享一个在 JavaScript中,实现一个鼠标移入可以随机变换颜色,本质就是js的随机数运用. 代码如下: <!DOCTYPE html> <html> <head ...

  5. HTML部分

    1.说一下<label>标签的用法 label标签主要是方便鼠标点击使用,扩大可点击的范围,增强用户操作体验 2.说一下事件代理? 事件委托是指将事件绑定到目标元素的父元素上,利用冒泡机制 ...

  6. java基础-01代理类

    简单的代理类实现案例主实现类:ProxyTestimport java.lang.reflect.InvocationHandler;import java.lang.reflect.Proxy;im ...

  7. LVS负载均衡理论以及算法概要

    一. LVS简介 LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 由章文嵩博士发起的自由软件项目,它的官方站点是www.linuxvirtualserver.or ...

  8. 浅谈linux IO csy 360技术 2021-01-18

    浅谈linux IO csy 360技术 2021-01-18

  9. maven打包三种方式

    https://blog.csdn.net/w820896059/article/details/80423143

  10. WPF Selector、SelectIndex、SelectedValue、SelectedValuePath、SelectedItem这几兄弟你分的清楚嘛?

    Selector Selector是一个抽象类,继承ItemsControl类(包含任何类型的对象(例如字符串,图像或面板)的集合),而本文的4个兄弟都是Selector类下的4个属性. Select ...