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 }
  • 相关阅读:
    Android网页打开指定App
    使用Android Studio Gradle实现友盟多渠道打包
    Android开发 PopupWindow弹窗调用第三方地图(百度,高德)实现导航功能
    Android使用Mob ShareSDK 分享不同平台
    Android布局优化之层级优化
    (Facebook开源项目)Fresco:一个新的Android图像处理类库
    关于Android开发的几点建议
    [AndroidTips]startService与bindService的区别
    基于HBase的手机数据备份系统 .
    MySQL在CenterOS和Ubuntu的安装
  • 原文地址:https://www.cnblogs.com/cszlg/p/2981163.html
Copyright © 2011-2022 走看看