首页 > ACM题库 > HDU-杭电 > HDU 3774-Ropes[解题报告]HOJ
2015
04-10

HDU 3774-Ropes[解题报告]HOJ

Ropes

问题描述 :

When climbing a section or “pitch”, the lead climber ascends first, taking a rope with them that they anchor to the rock for protection to ascend. Once at the top of a pitch, the lead climber has the second climber attach to the rope, so they can ascend with the safety of the rope. Once the second climber reaches the top of the pitch, the third attaches, and so on until all the climbers have ascended.
For example, for a 10 meter pitch and 50 meter rope, at most 6 climbers could ascend, with the last climber attaching to the end of the rope. To ascend safely, there must be at least 2 climbers and the rope must be at least as long as the pitch.
This process is repeated on each pitch of the climb, until the top is reached. Then to descend, the climbing rope is hung at its midpoint from an anchor (each half must reach the ground).
The climbers then each rappel from this rope. The rope is retrieved from the anchor by pulling one side of the rope, slipping it though the anchor and allowing it to fall to the ground.
To descend safely, the rope must be at least twice as long as the sum of the lengths of the pitches.
For example, a 60 meter rope is required to rappel from a 30 meter climb, no matter how many climbers are involved.
Climbing ropes come in 50, 60 and 70 meter lengths. It is best to take the shortest rope needed for a given climb because this saves weight. You are to determine the maximum number of climbers that can use each type of rope on a given climb.

输入:

The input consists of a number of cases. Each case specifies a climb on a line, as a sequence of pitch lengths as in:
N P1 P2 … PN
Here N is the positive number of pitches, with 1 ≤ N ≤ 100, and Pk is the positive integer length (in meters) of each pitch, with 1 ≤ Pk ≤ 100. The last line (indicating the end of input) is a single 0.

输出:

The input consists of a number of cases. Each case specifies a climb on a line, as a sequence of pitch lengths as in:
N P1 P2 … PN
Here N is the positive number of pitches, with 1 ≤ N ≤ 100, and Pk is the positive integer length (in meters) of each pitch, with 1 ≤ Pk ≤ 100. The last line (indicating the end of input) is a single 0.

样例输入:

1 25
2 10 20
0

样例输出:

3 3 3
0 4 4

/*
分析:
    水题,不过题目真难读懂 – -I。

 len代表绳长、sum代表所有pitch的高度之和、max=最高的pitch,
那么:
    1、若len<2*sum,则不行;
 2、最多的人数=(50(60/70)/max)+1;
*/

 

 

 

#include"stdio.h"
int judge(int x,int sum,int max)
{
	if(sum*2>x)	return 0;
	return x/max+1;
}
int main()
{
	int n;
	int p[111],max,sum;
	int i;
	while(scanf("%d",&n),n)
	{
		max=0;
		sum=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&p[i]);
			sum+=p[i];
			if(p[i]>max)	max=p[i];
		}

		printf("%d ",judge(50,sum,max));
		printf("%d ",judge(60,sum,max));
		printf("%d\n",judge(70,sum,max));
	}
	return 0;
}

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

参考:http://blog.csdn.net/ice_crazy/article/details/7540294


  1. 第一句可以忽略不计了吧。从第二句开始分析,说明这个花色下的所有牌都会在其它里面出现,那么还剩下♠️和♦️。第三句,可以排除2和7,因为在两种花色里有。现在是第四句,因为♠️还剩下多个,只有是♦️B才能知道答案。