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 .
输入输出样例
说明
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[];
int main(){
cin>>n;
ans[]=;ans[]=;ans[]=;ans[]=;
for(int i=;i<=;i++)
ans[i]=*ans[i-]-*ans[i-]+ans[i-];
cout<<ans[n]<<endl;
}
CF909B Segments的更多相关文章
- [LeetCode] Number of Segments in a String 字符串中的分段数量
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...
- Greenplum记录(一):主体结构、master、segments节点、interconnect、performance monitor
结构:Client--master host--interconnect--segment host 每个节点都是单独的PG数据库,要获得最佳的性能需要对每个节点进行独立优化. master上不包含任 ...
- Application package 'AndroidManifest.xml' must have a minimum of 2 segments.
看了源码就是packagename里面必须包含一个. 源码在: ./sdk/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/id ...
- segments&cache
Segments 执行效果 命令 在 sense 里边执行 GET /abcd/_segments 前边的是索引名称,后边是请求 段信息 说明 索引是面向分片的,是由于索引是由一个或多个分片( ...
- [UCSD白板题] Points and Segments
Problem Introduction The goal in this problem is given a set of segments on a line and a set of poin ...
- [UCSD白板题] Covering Segments by Points
Problem Introduction You are given a set of segments on a line and your goal is to mark as few point ...
- MAPPING SEGMENTS TO PAGES
The segmentation and paging mechanisms provide in the support a wide variety of approaches to memory ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树 矩阵面积并
D. Vika and Segments Vika has an infinite sheet of squared paper. Initially all squares are whit ...
- Leetcode: Number of Segments in a String
Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...
随机推荐
- Linux 端口 为什么要有端口
ip能锁定一台物理机器,对应着一张网卡,外界发来的数据包网卡都会接收.但是问题来了,网卡给程序提供了接口,你监听一下我,要是有消息来了,我就转发给你.这样应用程序就能收到数据了.但是问题来了,程序A和 ...
- C语言之基本算法41—字符串匹配问题
//字符串匹配问题 /* =============================================================== 题目:输入两字符串S,T,输出在S中存在但在T ...
- First Day Python介绍
前言:刚开通的博客,谢谢博客园平台,管理辛苦! Python介绍 Python是一门高级的.面向对象的.解释性.脚本语言. 高级语言:贴近开发者,对应底层语言,底层语言贴近机器:java.C#.php ...
- redis实现计数--------Redis increment
经理提出新的需求,需要知道每天微信推送了多少条模板消息,成功多少条,失败多少条,想到用Redis缓存,网上查了一些资料,Redis中有方法increment,测试代码如下 Controller imp ...
- 【转】什么是P问题、NP问题和NPC问题
原文链接:http://www.matrix67.com/blog/archives/105,感谢Matrix67,看完这篇文章终于把这个几个概念弄明白了!! 这或许是众多OIer最大的误区之一. ...
- BZOJ 3991 set维护dfs序
思路: set按照dfn排序 两点之间的距离可以O(logn)算出来 加一个点-> now ans+=dis(pre,now)+dis(now,next)-dis(pre-next); 删一个点 ...
- ansible upload
# 链接地址:https://www.cnblogs.com/xiaoxiaoleo/p/6626299.html # synchronize: 从拉取远程服务器文件,需要加mode: pull # ...
- 关于React-native的介绍以及环境搭建
React-Native介绍(后面内容的RN就是指react-native) 由facebook公司推出的,基于react,能开发原生app 原理: 1. 利用react框架写好js代码 2. 利用p ...
- Spring学习笔记之依赖的注解(2)
Spring学习笔记之依赖的注解(2) 1.0 注解,不能单独存在,是Java中的一种类型 1.1 写注解 1.2 注解反射 2.0 spring的注解 spring的 @Controller@Com ...
- SurfaceView加载长图
1:SurfaceView加载长图,移到.可以充当背景 效果截图 2:View (淡入淡出动画没实现:记录下) package com.guoxw.surfaceviewimage; import a ...