2403. Voting || string
来源:互联网 发布:淘宝买身份证怎么搜 编辑:程序博客网 时间:2024/06/05 22:17
2403. Voting
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
A committee clerk is good at recording votes, but not so good at counting and figuring the outcome correctly. As a roll call vote proceeds, the clerk records votes as a sequence of letters, with one letter for every member of the committee:
Y means a yes vote
N means a no vote
P means present, but choosing not to vote
A indicates a member who was absent from the meeting
N means a no vote
P means present, but choosing not to vote
A indicates a member who was absent from the meeting
Your job is to take this recorded list of votes and determine the outcome.
Rules:
There must be a quorum. If at least half of the members were absent, respond "need quorum". Otherwise votes are counted. If there are more yes than no votes, respond "yes". If there are more no than yes votes, respond "no". If there are the same number of yes and no votes, respond "tie".
There must be a quorum. If at least half of the members were absent, respond "need quorum". Otherwise votes are counted. If there are more yes than no votes, respond "yes". If there are more no than yes votes, respond "no". If there are the same number of yes and no votes, respond "tie".
Input
The input contains of a series of votes, one per line, followed by a single line with the # character. Each vote consists entirely of the uppercase letters discussed above. Each vote will contain at least two letters and no more than 70 letters.
Output
For each vote, the output is one line with the correct choice "need quorum", "yes", "no" or "tie".
Sample Input
YNNAPYYNYYAYAYAYAPYPPNNYAYNNAANYAAA#
Sample Output
yesneed quorumtienoneed quorum
Problem Source
每周一赛第四场
代码:
#include <iostream>#include <string>using namespace std;int main () {string vote;while (cin>>vote && vote != "#") {int yes = 0;int no = 0;int abs = 0;for (int i = 0; i < vote.length(); i++) {if (vote[i] == 'Y')yes++;if (vote[i] == 'N')no++;if (vote[i] == 'A')abs++;}if (2*abs >= vote.length())cout<<"need quorum";else {if (yes > no)cout<<"yes";if (no > yes)cout<<"no";if (yes == no)cout<<"tie";}cout<<endl;}//system("pause");return 0;}
0 0
- 2403. Voting || string
- 2403. Voting
- Sicily 2403. Voting
- voting设计模式
- Block Voting --解题报告
- DP_poj3022_The Uxuhul Voting System
- UvaOJ 10142 - Australian Voting
- RAC Voting介绍
- Uva-10142-Australian Voting
- UVA10142/PC110108Australian Voting
- UVa 10142 Australian Voting
- 管理voting disks
- Moore's voting algorithm
- Moore’s voting algorithm
- csu 1535: Pizza voting
- UVa 10142 - Australian Voting
- Moore's voting algorithm
- Managing Voting Disks
- UIView的深入研究《转》
- C# 序列化与反序列化几种格式的转换
- 29句最常用的英语谚语——管理…
- iSecret 用户反馈专用
- NSDateComponents 的基本使用以及…
- 2403. Voting || string
- iOS 招聘 准备资料
- 我的处女贴: UITableView reloadDa…
- Operation Queue(Obj-C中并发的…
- iOS 开发资源汇总《转》
- iOS push 相关知识备忘
- Mysql导入导出.sql文件《转》
- Django 数据库事务
- Mysql for MacOSX 安装和基本操作