CF909B.Segments

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be of them.

You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoints though). You can not move the segments to a different location on the coordinate axis.

Find the minimal number of layers you have to use for the given N.

给你一个整数 NN。考虑所有在坐标轴上的线段,其端点均为整数坐标,且坐标值均在 00 到 NN(含)之间;这样的线段共有 条。

你需要将这些线段绘制在若干层上,使得每一层内的线段互不重叠(但允许在端点处相接)。你不能将线段在坐标轴上移动到其他位置。

对于给定的 NN,求所需的最少层数。

输入格式

The only input line contains a single integer N (1 ≤ N ≤ 100).

唯一的一行输入包含一个整数 NN(1≤N≤1001 \leq N \leq 100)。

输出格式

Output a single integer - the minimal number of layers required to draw the segments for the given N.

输出一个整数——绘制给定 NN 对应的线段所需的最少层数。

输入输出样例

  • 输入#1

    2

    输出#1

    2
  • 输入#2

    3

    输出#2

    4
  • 输入#3

    4

    输出#3

    6

说明/提示

As an example, here are the segments and their optimal arrangement into layers for N = 4.

例如,下图展示了当 N=4N = 4 时,各线段及其在层中的最优排列方式。

输入解题思路,AI测评打分。不知道怎么写?

首页