博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lightoj1249——Chocolate Thief (模拟)
阅读量:2344 次
发布时间:2019-05-10

本文共 2182 字,大约阅读时间需要 7 分钟。

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 next n 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 between 1 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’ where x 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

Output for Sample Input

Case 1: mun took chocolate from all

Case 2: no thief

简单的模拟,最多两个人的巧克力不一样,排序下就行

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 2005#define Mod 10001using namespace std;struct Node{ string name; int cube;};Node p[MAXN];bool cmp(Node a,Node b){ return a.cube
>p[i].name>>x>>y>>z; p[i].cube=x*y*z; } sort(p,p+n,cmp); cout<<"Case "<
<<": "; if(p[0].cube!=p[n-1].cube) { cout<
<<" took chocolate from "<
<

转载地址:http://ipcvb.baihongyu.com/

你可能感兴趣的文章
数据库DDL,DML,DCL,TCL
查看>>
各大数据库概述,比较
查看>>
子页面跳转
查看>>
常用算法总结
查看>>
数据库连接池
查看>>
JAVA Webservice
查看>>
Hibernate自动生成实体类
查看>>
Java Memcached
查看>>
JAVA WebSpider
查看>>
XML自动建表/存库
查看>>
Java实现Web服务器
查看>>
C# readonly与const的区别
查看>>
MFC 自定义消息的一般过程
查看>>
剖析Windows消息处理机制
查看>>
多线程入门教程(二)基本概念
查看>>
多线程入门教程(三)线程控制
查看>>
多线程入门教程(四)线程间通信
查看>>
多线程入门教程(五)MFC的多线程
查看>>
多线程入门教程(六)综合实例
查看>>
C/C++ 多线程学习心得
查看>>