B. Cows and Poker Game

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN".

Find the number of cows that can currently show their hands without affecting any betting decisions.

Input

The first line contains a single integer, n (2 ≤ n ≤ 2·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED".

Output

The first line should contain a single integer denoting the number of players that can currently show their hands.

Sample test(s)
input
6
AFFAAA
output
4
input
3
AFI
output
1
Note

In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand.



解题说明:此题只需要统计A ,I这两个字母出现的个数即可,注意以I出现次数是否超过1作为分类讨论的依据


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

int main()
{
	int n,i;
	int count1,count2,count3;
	char a[200005];
	scanf("%d",&n);
	scanf("%s",&a);
	count1=0;
	count2=0;
	count3=0;
	for(i=0;a[i]!='\0';i++)
	{
		if(a[i]=='A')
		{
			count1++;
		}
		else if(a[i]=='F')
		{
			count2++;
		}
		else
		{
			count3++;
		}
	}
	if(count3==1)
	{
		printf("1\n");
	}
	else if(count3>1)
	{
		printf("0\n");
	}
	else
	{
		printf("%d\n",count1);
	}
	return 0;
}


你可能感兴趣的:(B. Cows and Poker Game)