zoukankan      html  css  js  c++  java
  • POJ 1547:Clay Bully

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


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

  • 相关阅读:
    Objective-C中不同方式实现锁(二)-11-多线程
    共享资源加锁的操作方法-10-多线程
    ios 下锁使用- 09-多线程
    iOS开发-线程安全-09-多线程
    线程同步-iOS多线程编程指南(四)-08-多线程
    《GCD 实现同步锁》-07-多线程
    死锁-06-多线程
    生产者消费者问题-05-多线程
    递归锁+条件锁+互斥锁-04-多线程
    Android开发技术周报 Issue#62
  • 原文地址:https://www.cnblogs.com/lightspeedsmallson/p/4785799.html
Copyright © 2011-2022 走看看