CF909B Segments

题意翻译

题目描述

给你一个整数N。考虑坐标轴上所有可能的部分,在整数点上的端点,坐标在0到N之间,包括它们。 您希望在几个层中绘制这些片段,这样在每个层中这些片段就不会重叠(尽管它们可能会接触到端点)。不能将这些段移动到坐标轴上的另一个位置。 找出给定N必须使用的最低层数。

输入格式:

唯一的输入行包含一个整数N(1<=N<=100)。

输出格式:

输出一个整数为给定的N绘制片段所需的最低层数。 采纳:鲁罗啵天霸

题目描述

You are given an integer NN . Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and NN , 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 NN .

输入输出格式

输入格式:

 

The only input line contains a single integer NN ( 1<=N<=1001<=N<=100 ).

 

输出格式:

 

Output a single integer - the minimal number of layers required to draw the segments for the given 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=4N=4 .

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int ans[105];
int main(){
    cin>>n; 
    ans[1]=1;ans[2]=2;ans[3]=4;ans[4]=6;
    for(int i=5;i<=100;i++)
        ans[i]=2*ans[i-1]-2*ans[i-3]+ans[i-4];
    cout<<ans[n]<<endl;
}

 

转载于:https://www.cnblogs.com/cangT-Tlan/p/8441478.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值