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;
}

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

POJ 1547:Clay Bully的更多相关文章

  1. POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)

    http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...

  2. POJ 3252:Round Numbers

    POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...

  3. POJ 1459:Power Network(最大流)

    http://poj.org/problem?id=1459 题意:有np个发电站,nc个消费者,m条边,边有容量限制,发电站有产能上限,消费者有需求上限问最大流量. 思路:S和发电站相连,边权是产能 ...

  4. POJ 3436:ACM Computer Factory(最大流记录路径)

    http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2* ...

  5. POJ 2195:Going Home(最小费用最大流)

    http://poj.org/problem?id=2195 题意:有一个地图里面有N个人和N个家,每走一格的花费是1,问让这N个人分别到这N个家的最小花费是多少. 思路:通过这个题目学了最小费用最大 ...

  6. POJ 3281:Dining(最大流)

    http://poj.org/problem?id=3281 题意:有n头牛,f种食物,d种饮料,每头牛有fnum种喜欢的食物,dnum种喜欢的饮料,每种食物如果给一头牛吃了,那么另一个牛就不能吃这种 ...

  7. POJ 3580:SuperMemo(Splay)

    http://poj.org/problem?id=3580 题意:有6种操作,其中有两种之前没做过,就是Revolve操作和Min操作.Revolve一开始想着一个一个删一个一个插,觉得太暴力了,后 ...

  8. POJ 3237:Tree(树链剖分)

    http://poj.org/problem?id=3237 题意:树链剖分.操作有三种:改变一条边的边权,将 a 到 b 的每条边的边权都翻转(即 w[i] = -w[i]),询问 a 到 b 的最 ...

  9. POJ 2763:Housewife Wind(树链剖分)

    http://poj.org/problem?id=2763 题意:给出 n 个点, n-1 条带权边, 询问是询问 s 到 v 的权值, 修改是修改存储时候的第 i 条边的权值. 思路:树链剖分之修 ...

随机推荐

  1. 猎鹰9火箭(Falcon 9)

    翻译自:https://www.spacex.com/falcon9 使用了有道词典的翻译,以及本人的修正. 猎鹰9号是SpaceX公司设计和制造的两级火箭,用于可靠和安全地将卫星和“龙”号宇宙飞船送 ...

  2. 一步步教你整合SSM框架(Spring MVC+Spring+MyBatis)详细教程重要

    前言 SSM(Spring+SpringMVC+Mybatis)是目前较为主流的企业级架构方案,不知道大家有没有留意,在我们看招聘信息的时候,经常会看到这一点,需要具备SSH框架的技能:而且在大部分教 ...

  3. Linux基础命令、软件安装

    常用命令 查看当前系统中存在哪些shell cat /etc/shells [root@** ~]# cat /etc/shells /bin/sh /bin/bash /usr/bin/sh /us ...

  4. jpa自定义sql语句

    /** * 查询还没生成索引的帖子 * @return */ @Query(value = "SELECT * FROM t_article WHERE index_state=0" ...

  5. 5 GC 参数

  6. jQuery事件 - toggle() 方法

    1.切换元素的显示与隐藏状态 实例 切换 <p> 元素的显示与隐藏状态: $(".btn1").click(function(){ $("p").h ...

  7. 原生JS 实现 dom ready

    记录一下项目技术问题: 记得:放在head标签内的脚本,第一时间执行 var baseTools = { // dom ready ready: function( f ){ var ie = !!( ...

  8. cmd命令打开本地*.db数据文件的一些坑

    昨天刚看了下sqlite数据库,用的是cmd窗口 写的,建了几个表,今天在次打开,发现.问题有点小多啊.. 我也不知道我的数据库名字后面为啥会带  (“ : ”) 下面是我的数据文件: 刚开始看了下, ...

  9. UVA 12511/CSU 1120 virus 最长公共上升子序列

    第一次接触一个这最长公共上升子序列 不过其实搞清楚了跟最长公共子序列和 最长上升子序列如出一辙 两重循环,对于当前不相等的,等于前一个的值,相等的,等于比当前A[i]小的最大值+1.弄个临时变量记录最 ...

  10. SSM 整合配置以及一个简单登陆案例(个人记录)

    SSM 文件以及大部分参考博客 https://blog.csdn.net/qq598535550/article/details/51703190 简答的登陆注册案例下载链接在末尾补贴图了 我建立的 ...