zoukankan      html  css  js  c++  java
  • Codeforces Round #174 (Div. 2) B. Cows and Poker Game(简单)

    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.

    AC Code:

     1 #include <iostream>
     2 #include <fstream>
     3 #include <string>
     4 #include <set>
     5 #include <map>
     6 #include <vector>
     7 #include <stack>
     8 #include <queue>
     9 #include <cmath>
    10 #include <cstdio>
    11 #include <cstring>
    12 #include <algorithm>
    13 #include <utility>
    14 using namespace std;
    15 #define ll long long
    16 #define cti const int
    17 #define ctll const long long
    18 #define dg(i) cout << '*' << i << endl;
    19 
    20 int n, in, fo, al, ans;
    21 char a[200005];
    22 
    23 int main()
    24 {
    25     while(cin >> n)
    26     {
    27         ans = al = fo = in = 0;
    28         scanf("%s", a);
    29         for(int i = 0; i < n; i++)
    30         {
    31             if(a[i] == 'F') fo++;
    32             else if(a[i] == 'A') al++;
    33             else in++;
    34         }
    35         if(al && !in) ans += al;
    36         else if(in == 1) ans++;
    37         printf("%d\n", ans);
    38     }
    39     return 0;
    40 }
  • 相关阅读:
    RabbitMQ消息队列———安装(一)
    Tornado之自定义异步非阻塞的服务器和客户端
    爬虫之解析微信的网页版(分析后台,不分析前端)
    阻塞I/O、非阻塞I/O和I/O多路复用
    Git之安装管理
    MongoDB下载以及安装
    Python3学习笔记(十六):随机数模块random
    Python3学习笔记(十五):常用时间模块time和datetime
    Python3学习笔记(十四):可迭代对象、迭代器和生成器
    unittest详解(七) 自动生成测试报告
  • 原文地址:https://www.cnblogs.com/cszlg/p/2981163.html
Copyright © 2011-2022 走看看