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的棋盘,每天都在棋盘上面放一颗棋子 ...
随机推荐
- Mac下使用crontab来实现定时任务
说明: 1.Linux和Mac下操作crontab都是一致的 2.配置文件都在/etc/crontab下,如果没有就创建. 3.测试发现直接使用crontab -e命令创建的定时任务是放在临时文件夹的 ...
- 深度学习(十五) TextCNN理解
以下是阅读TextCNN后的理解 步骤: 1.先对句子进行分词,一般使用“jieba”库进行分词. 2.在原文中,用了6个卷积核对原词向量矩阵进行卷积. 3.6个卷积核大小:2个4*6.2个3*6和2 ...
- C 标准库 - ctype.h之iscntrl 使用
iscntrl int iscntrl ( int c ); Check if character is a control character 检查给定字符是否为控制字符,即编码 0x00-0x1F ...
- Perl入门
Perl 是一门开源的脚本语言,由 Larry Wall 所创造,该语言以实用,快速开发为主要目标,与当前流行的面向对象结构化编程有些格格不入,但这并不妨碍 Perl 被广泛流传和使用,世界范围内围绕 ...
- 使用HTML+CSS实现鼠标划过的二级菜单栏
先上效果图: 1.鼠标没在上面 2.鼠标放在一级菜单上,展开二级菜单 3.鼠标放在二级菜单上 代码: (点击此处预览代码效果) <html> <head> <title& ...
- JAVA是否允许返回值类型不同的重载overload或覆盖override
在看<Thinking in java>的时候,看到子类的方法和父类的方法名字相同,但是返回值类型不同,然后就开始怀疑这属于覆盖吗,到网上找到了答案,分析见接下来的网址: http://g ...
- 周记6——css实现类似朋友圈九宫格缩略图完美展示
公司有在做一个类似qq空间的开发,发表说说避免不了的要有图片展示. 产品提出的空间缩略图的展示类似*信朋友圈那种效果--图片不变形.能看到中间部分. 这里给出3种解决方案(jsbin地址失效时可复制代 ...
- java并发编程(5)并发程序测试
并发程序测试 一.正确性测试 如:对一个自定义缓存的测试 //自定义的缓存 public class SemaphoreBoundedBuffer <E> { private final ...
- easyform表单校验插件改版源码
改动特性: 1.支持回调,可用于ajax提交 2.提示框样式修改,原版太丑,修改成bootstrap的popover 样式 原版还存在缺陷:被校验的表单元素设置不灵活,还得加上id.name 什么的 ...
- 基于ASP.NET Core 创建 Web API
使用 Visual Studio 创建项目. 文件->新建->项目,选择创建 ASP.NET Core Web 应用程序. 基于 ASP.NET Core 2.0 ,选择API,身份验证选 ...