POJ 1547:Clay Bully

在每堂艺术课上,教师Terry发现了一个问题:一些孩子从其他孩子那里拿走了过多的粘土。通过测量每个孩子完成的作品尺寸,任务是找出谁在作弊,以及他们从谁那里拿了粘土。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Clay Bully
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 8349 Accepted: 4711

Description

Ms. Terry is a pre-school art teacher who likes to have her students work with clay. One of her assignments is to form a lump of clay into a block and then measure the dimensions of the block. However, in every class, there is always one child who insists on taking some clay from some other child. Since Ms. Terry always gives every child in a class the same amount of clay to begin with, you can write a program that helps Ms. Terry find the bully and victim after she measures each child's finished block.

Input

There are one or more classes of students, followed by a final line containing only the value -1. Each class starts with a line containing an integer, n, which is the number of students in the class, followed by n lines of student information. Each line of student information consists of three positive integers, representing the dimensions of the clay block, followed by the student's first name. There can never be more than 9 students nor less than 2 students in any class. Each student's name is at most 8 characters. Ms. Terry always gives each student at most 250 cubic units of clay. There is exactly one bully and one victim in each class.

Output

For each class print a single line exactly as shown in the sample output.

Sample Input

3
10 10 2 Jill
5 3 10 Will
5 5 10 Bill
4
2 4 10 Cam
4 3 7 Sam
8 11 1 Graham
6 2 7 Pam
-1

Sample Output

Bill took clay from Will.
Graham took clay from Cam.

题意是老师本来给每个人的泥土是一样多的,但是有人从其他一个人那里多拿了泥土,给了每一个人泥土的体积,问谁多拿了谁的。

洪水滔天。求最大与最小。

代码:

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std;

int stu[15];
string name[15];

int main()
{	
	int num,i;
	while(cin>>num)
	{
		if(num==-1)
			break;
		int temp1,temp2,temp3;
		for(i=1;i<=num;i++)
		{
			cin>>temp1>>temp2>>temp3>>name[i];
			stu[i]=temp1*temp2*temp3;
		}
		int min_n=700,min_x;
		int max_n=-1,max_x;
		
		for(i=1;i<=num;i++)
		{
			if(stu[i]>max_n)
			{
				max_x=i;
				max_n=stu[i];
			}
			if(stu[i]<min_n)
			{
				min_x=i;
				min_n=stu[i];
			}
		}
		cout<<name[max_x]<<" took clay from "<<name[min_x]<<"."<<endl;
	}
	return 0;
}


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

转载于:https://www.cnblogs.com/lightspeedsmallson/p/4785799.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值