Bootstrap

E - Voting(模拟)

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 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’.

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

YNNAPYYNY

YAYAYAYA

PYPPNNYA

YNNAA

NYAAA

#

Sample Output

yes

need quorum

tie

no

need quorum

 

【解析】

题意:投票,Y表示同意,N表示反对,P表示中立,A表示缺席,超过半数出席,投票才是有效的。问是否通过。

#include <bits/stdc++.h>
using namespace std;
int main()
{
	char s[1010];
	while (~scanf("%s", s))
	{
		if (s[0] == '#')break;
		int absent = 0, flag = 1, yes = 0, no = 0;
		int len = strlen(s);
		for (int i = 0; i < len; i++)
		{
			if (s[i] == 'A')absent++;
			if (absent >= len/2.0)
			{
				flag = 0;
				break;
			}
			if (s[i] == 'Y')yes++;
			else if (s[i] == 'N')no++;
		}
		if (flag)
		{
			if (yes > no)printf("yes\n");
			else if (no > yes)printf("no\n");
			else printf("tie\n");
		}
		else printf("need quorum\n");
	}
	return 0;
}

 

;