Clay Bully
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 8360 | Accepted: 4717 |
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.
Source
/***********************************************************************
Copyright (c) 2015,wangzp
All rights no reserved.
Name: 《Clay Bully》In PEKING UNIVERSITY ACM
ID: PROBLEM 1447
问题简述: 分泥巴,相同的泥巴,但是其中一个小朋友欺负另一个小朋友,
偷了他的泥巴,请把这个小朋友找出来。
Date: SEP 09, 2015
***********************************************************************/
#include
#include
#define LEN 9
#define CUBIC 250 //题中说正确的人都分到了250个方的泥巴
typedef struct{
short len;
short wide;
short high;
char stu_name[LEN];
}STUDENT;
int main(void)
{
int n,i;
STUDENT stu[LEN];
int stu_kind;
int stu_evil;
int max_n,min_n;
int tmp_v;
scanf("%d",&n);
while(n != -1)
{
max_n = 0;
min_n = CUBIC;
tmp_v = 0;
stu_evil = 0;
stu_kind = 0;
for (i = 0;i < n;i++)
{
memset(stu[i].stu_name,0,sizeof(char)*9);//最好再次输入时把名字都清空
,有的名字长的可能会影响
scanf("%d %d %d %s",&stu[i].len,&stu[i].wide,&stu[i].high,stu
[i].stu_name);
tmp_v = stu[i].len * stu[i].wide * stu[i].high;
if(tmp_v > max_n)
{
max_n = tmp_v;
stu_evil = i;
}
if (tmp_v < min_n)
{
min_n = tmp_v;
stu_kind = i;
}
}
printf("%s took clay from %s.\n",stu[stu_evil].stu_name,stu
[stu_kind].stu_name);
scanf("%d",&n);
}
return 0;
}