zoukankan      html  css  js  c++  java
  • 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;
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    Hive metastore三种配置方式
    hive学习(一)hive架构及hive3.1.1三种方式部署安装
    hiveserver2的配置和启动
    spark安装配置
    Sqoop-1.4.6安装部署及详细使用介绍
    搭建本地yum源服务器
    Centos7.X安装impala(RPM方式)
    Hive安装与配置详解
    【图文详解】Hadoop集群搭建(CentOs6.3)
    Linux下实现免密码登录(超详细)
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/8441478.html
Copyright © 2011-2022 走看看