LightOJ - 1249 Chocolate Thief (模拟)

LightOJ - 1249
Chocolate Thief
Time Limit:                                                        1000MS                        Memory Limit: 32768KB 64bit IO Format:                            %lld & %llu                       

SubmitStatus

Description

I gave some chocolates to students for their extraordinary performances. A chocolate is a cube shaped thing, which has length, width and height. All the students got the same amount of chocolates; their dimensions may be different but the volumes are same.

Now some of the students are claiming that there is one chocolate thief amongst them. So, it's not an easy task for me to find the chocolate thief, so I am asking your help.

You are given the names of the students and the dimensions of their chocolates; you have to find the name of the chocolate thief. You can assume that there can be at most one thief and if there is a thief, he took some portion of the chocolate from another student (not students).

Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case starts with a line containing an integer n (2 ≤ n ≤ 100) denoting the number of students. Each of the nextn lines contains a name and three integers denoting the length, width and height of his current chocolate share. Names are strings containing alphanumeric characters and the length of a name is between1 and 20. And length, width and height will lie in the range[1, 100]. Input follows the above restrictions.

Output

For each case, print the case number first. Then if no thief is found, print 'no thief'. Otherwise print 'x took chocolate from y' wherex is the name of the chocolate thief, and y is the name of the person from whom the chocolate was taken.

Sample Input

2

11

atq 3 4 3

mun 10 4 1

sam1 6 6 1

sam2 18 2 1

mub 1 36 1

tan 1 4 9

sha 4 3 3

di 3 12 1

nab 2 2 9

all 8 4 1

fah 3 2 6

2

ja 10 10 10

em 2 50 10

Sample Output

Case 1: mun took chocolate from all

Case 2: no thief

Hint

Source

Problem Setter: Jane Alam Jan
//题意:
刚开始时每个人都有一块形状不同,但价值相同的巧克力,但是现在他们中可能有个人偷了另一个同学的巧克力,请找出来这个人并输出着这个人偷了那个人的巧克力。
 
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
	int s[100];
	int sum;
}p[10000];
bool cmp(node s1,node s2)
{
	return s1.sum<s2.sum;
}
int main()
{
	int t,k=1;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		int x,y,z;
		for(int i=0;i<n;i++)
		{
			scanf("%s%d%d%d",p[i].s,&x,&y,&z);
			p[i].sum=x*y*z;
		}
		sort(p,p+n,cmp);
		if(p[0].sum==p[n-1].sum)
		printf("Case %d: no thief\n",k++);
		else
		printf("Case %d: %s took chocolate from %s\n",k++,p[n-1].s,p[0].s);
	}
	return 0;
}

你可能感兴趣的:(LightOJ - 1249 Chocolate Thief (模拟))