第七届河南省程序设计大赛——H Rectangles

第七届河南省程序设计大赛中涉及一个矩形嵌套问题,要求编写程序找出给定N个矩形中,最大能有多少个矩形可以相互嵌套。条件是大矩形的一边必须严格大于小矩形的对应边,且另一条边不小于小矩形的对应边。题目提供输入输出描述,并给出样例示例。解决方法是首先根据矩形的长边排序,如果有相同的长边则按照短边排序。
摘要由CSDN通过智能技术生成

题目描述:

Given N (4 <= N <= 100)  rectangles and the lengths of their sides ( integers in the range 1..1,000), write a program that finds the maximum K for which there is a sequence of K of the given rectangles that can "nest", (i.e., some sequence P1, P2, ..., Pk, such that P1 can completely fit into P2, P2 can completely fit into P3, etc.).

 

A rectangle fits inside another rectangle if one of its sides is strictly smaller than the other rectangle's and the remaining side is no larger.  If two rectangles are identical they are considered not to fit into each other.  For example, a 2*1 rectangle fits in a 2*2 rectangle, but not in another 2*1 rectangle.

 

The list can be created from rectangles in any order and in either or

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值