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 }
  • 相关阅读:
    (九)MySQL数据库
    (八)其他组件(redis、zk、dubbo、MQ、ES)
    (七)Spring体系
    (六)JVM虚拟机
    (五)并发编程与锁机制
    (四)常用集合与原理
    (三)JDK版本区别
    k8s scheduler framework 配置weight不生效的问题
    Elasticsearch ILM delete not working
    etcd 依赖采坑
  • 原文地址:https://www.cnblogs.com/cszlg/p/2981163.html
Copyright © 2011-2022 走看看