ZOJ Problem Set – 2321 Filling Out the Team
Time Limit: 2 Seconds Memory Limit: 65536 KB

Over the years, the people of the great city of Pittsburgh have repeatedly demonstrated a collective expertise at football second to none. Recently a spy has discovered the true source of the city's football power-a wizard known only as "Myron," who is infallible at selecting the proper position at which each player will excel.
Now that you know the source of Pittsburgh's wisdom, you are determined to provide your school's football team with a computer program that matches the wisdom of "Myron." You have consulted with the best football minds you can find, and they have dispensed their wisdom on the slowest speed, minimum weight, and minimum strength required to play each position.
|
Position |
Slow.Speed |
Min.Weight |
Min.Strength |
|
Wide Receiver |
4.5 |
150 |
200 |
|
Lineman |
6.0 |
300 |
500 |
|
Quarterback |
5.0 |
200 |
300 |
Using this knowledge, you will develop a program that reads in several players physical attributes and outputs what position(s) they are able to play.
Input
Each line of the input file will list the attributes for one player:
<speed> <weight> <strength>
Each number will be a real-valued number. The file will end with a line reading "0 0 0".
Output
For each player, you will output one line listing the positions that player can play. A player can play a position if each of their attributes is greater or equal to the minimum for weight and strength, and less than or equal to the slowest speed. If a player can play multiple positions, output them in the order listed above, separated by whitespace. You can not leave an extra space at the end of the line. If a player can play no positions, write "No positions" on the line.
Sample Input
4.4 180 200
5.5 350 700
4.4 205 350
5.2 210 500
0 0 0
Sample Output
Wide Receiver
Lineman
Wide Receiver Quarterback
No positions

Source: Mid-Atlantic USA 2004
#include<iostream>
#include<map>
#include<string>
using
namespace
std;
class
Position
{
private:
string
name;
double
lowestSpeed;
double
minWeight;
double
minStrength;
public:
Position(){}
string
GetName()
{
return
this->name;
}
Position(string
name,
double
lowestSpeed,
double
minWeight,
double
minStrength)
{
this->name=name;
this->lowestSpeed
=
lowestSpeed;
this->minWeight
=
minWeight;
this->minStrength
=
minStrength;
}
bool
MathPosition(double
speed,
double
weight,
double
strength)
{
return
(weight
>=
this->minWeight
&&
strength
>=
this->minStrength
&&
speed
<=
this->lowestSpeed);
}
};
int
main()
{
Position
**p
=
new
Position*[3];
*p
=
new
Position("Wide Receiver",
4.5,
150,
200);
*(p+1)
=
new
Position("Lineman",
6.0,
300,
500);
*(p+2)
=
new
Position("Quarterback",
5.0,
200,
300);
double
s,
w,
str;
while(cin>>s>>w>>str
&&
(s
!=
0
||
w
!=
0
||
str
!=
0))
{
int
matchCount
=
0;
if((*p)->MathPosition(s,w,str)){
cout<<(*p)->GetName();
matchCount++;
}
if((*(p+1))->MathPosition(s,w,str)){
if(matchCount
!=
0)
cout<<" ";
cout<<(*(p+1))->GetName();
matchCount++;
}
if((*(p+2))->MathPosition(s,w,str)){
if(matchCount
!=
0)
cout<<" ";
cout<<(*(p+2))->GetName();
matchCount++;
}
if(matchCount
==
0)
cout<<"No positions";
cout<<endl;
}
delete[]
p;
p
=
NULL;
return
0;
}
ZOJ Problem Set – 2321 Filling Out the Team的更多相关文章
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1025解题报告
ZOJ Problem Set - 1025 题目分类:基础题 原题地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=10 ...
- ZOJ Problem Set - 3829Known Notation(贪心)
ZOJ Problem Set - 3829Known Notation(贪心) 题目链接 题目大意:给你一个后缀表达式(仅仅有数字和符号),可是这个后缀表达式的空格不幸丢失,如今给你一个这种后缀表达 ...
- ZOJ Problem Set - 2563 Long Dominoes 【如压力dp】
称号:ZOJ Problem Set - 2563 Long Dominoes 题意:给出1*3的小矩形.求覆盖m*n的矩阵的最多的不同的方法数? 分析:有一道题目是1 * 2的.比較火.链接:这里 ...
- ZOJ Problem Set - 3593 拓展欧几里得 数学
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...
- ZOJ Problem Set - 2297 Survival 【状压dp】
题目:ZOJ Problem Set - 2297 Survival 题意:给出一些怪,有两个值,打他花费的血和能够添加的血,然后有一个boss,必须把小怪全部都打死之后才干打boss,血量小于0会死 ...
- ZOJ Problem Set - 3820 Building Fire Stations 【树的直径 + 操作 】
题目:problemId=5374" target="_blank">ZOJ Problem Set - 3820 Building Fire Stations 题 ...
- ZOJ Problem Set - 3229 Shoot the Bullet 【有上下界网络流+流量输出】
题目:problemId=3442" target="_blank">ZOJ Problem Set - 3229 Shoot the Bullet 分类:有源有汇 ...
- ZOJ Problem Set - 3822Domination(DP)
ZOJ Problem Set - 3822Domination(DP) problemCode=3822">题目链接 题目大意: 给你一个n * m的棋盘,每天都在棋盘上面放一颗棋子 ...
随机推荐
- Sql语句里的递归查询 SqlServer2005和Oracle 两个版本
以前使用Oracle,觉得它的递归查询很好用,就研究了一下SqlServer,发现它也支持在Sql里递归查询举例说明:SqlServer2005版本的Sql如下:比如一个表,有id和pId字段,id是 ...
- (转)OpenStack各服务所用端口号总结
参考:Firewalls and default ports 注:可执行 sudo netstat -tnlp 查看 端口 服务描述 22 SSH 3306 MariaDB(MySQL) 27017 ...
- C# 文件读写系列二
读取文件原则上非常简单,但它不是通过FileInfo和DirectoryInfo来完成的,关于FileInfo和DirectoryInfo请参考C# 文件操作系列一,在.Net Framework4. ...
- JS框架设计之命名空间设计一种子模块
命名空间 1.种子模块作为一个框架的最开始,除了负责初始化框架的最基础部分. 2.种子模块作为框架的最开始,那么什么是种子框架的最开始呢?答案是IIFE(立即调用函数表达式); IIFE(立即调用函数 ...
- LeetCode-13. Roman to Integer(罗马数字转阿拉伯数字)
1.题目描述 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range f ...
- R语言 删除变量rm函数
变量可以通过使用 rm()函数来删除.下面我们删除变量var.3.然后再打印变量时出现异常错误. rm(var.3) print(var.3) 当上面的代码执行时,它产生以下结果: [1] " ...
- IOS仿微信朋友圈好友展示
前几天小伙伴要帮他做一个群聊功能,里面有好友列表,要求和微信的差不多(见下图),让小伙伴自己实现了下,他将CollectionView放在tableView的tableHead中,可是当添加好友或删除 ...
- RxJS库
介绍 RxJS是一个异步编程的库,同时它通过observable序列来实现基于事件的编程.它提供了一个核心的类型:Observable,几个辅助类型(Observer,Schedulers,Subje ...
- 第4章 scrapy爬取知名技术文章网站(2)
4-8~9 编写spider爬取jobbole的所有文章 # -*- coding: utf-8 -*- import re import scrapy import datetime from sc ...
- C# 核心语法-反射(反射类型、方法、构造函数、属性,实现可配置可扩展,完成数据库访问类反射封装)
反射是.NET中的重要机制,通过反射,可以在运行时获得程序或程序集中每一个类型(包括类.结构.委托.接口和枚举等)的成员和成员的信息.有了反射,即可对每一个类型了如指掌.另外我还可以直接创建对象,即使 ...