Light 1249-Chocolate Thief【模拟】
来源:互联网 发布:thinkphp视频网站源码 编辑:程序博客网 时间:2024/06/06 12:56
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
Output for 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
Case 1: mun took chocolate from all
Case 2: no thief
#include <cstdio>#include <cstring>#include <iostream>using namespace std;struct student{char name[29];int l, w, h, s;} c[1005];int main(){int t, Q=1; scanf("%d",&t);while(t--){int sum=0;int n; scanf("%d",&n);for(int i=0; i<n; i++){scanf("%s %d %d %d", c[i].name, &c[i].l, &c[i].w, &c[i].h);c[i].s= c[i].l*c[i].w*c[i].h;sum += c[i].s;}int ave=sum/n;char thief[29], bethief[29]; int Sum=0; for(int i=0; i< n; i++){if(c[i].s == ave)Sum++;if(c[i].s > ave){strcpy(thief,c[i].name);}if(c[i].s < ave){strcpy(bethief,c[i].name);}}if(Sum==n){printf("Case %d: no thief\n", Q++);continue;}printf("Case %d: %s took chocolate from %s\n", Q++, thief, bethief);}return 0;}
- Light 1249-Chocolate Thief【模拟】
- Light oj 1249 - Chocolate Thief【水】
- LightOJ - 1249 Chocolate Thief (模拟)
- Lightoj1249——Chocolate Thief (模拟)
- Light oj 1200 - Thief(水)
- Light oj 1200 - Thief 《完全背包》
- UVa 10970 Big Chocolate (模拟)
- 5.18特长生模拟题 Chocolate
- 【09 NOIP 模拟】light
- HDU 4112 Break the Chocolate(模拟)
- hdu 4112 Break the Chocolate(模拟)
- chocolate
- chocolate
- Light-oj 1078 (除法模拟)
- HDU 3644 A Chocolate Manufacturer's Problem(模拟退火)
- hdu 3644 A Chocolate Manufacturer's Problem(模拟退火)
- Light OJ 1214 Large Division 【模拟除法】
- Light oj 1261 - K-SAT Problem【模拟】
- hibernate session设置清理缓存的时间点(FlushMode属性的区别)
- 2D实现钟表效果
- java通过xml配置属性用iText包生成pdf文件
- Money Systems
- HTML 文本框 TextBox 内容改变事件
- Light 1249-Chocolate Thief【模拟】
- excel中以文本形式保存长数字
- Android Fragment 真正的完全解析(上)
- 网站加载速度特别慢,是怎么回事?
- 通过匿名内部类方式使用多线程
- java常用类
- 新年趣事之打牌
- 应用ruby打造个性化的有道单词本 (一)
- OpenCV Python教程(3)(4)(5): 直方图的计算与显示 形态学处理 初级滤波内