zoukankan      html  css  js  c++  java
  • BOJ 1561 Winner

    Winner
    Accept:8     Submit:15
    Time Limit:1000MS     Memory Limit:65536KB

    Winner

     

    Description

     

    Alice and Bob likes playing games. In each round, the one who wins will get one point. When one of them makes his/her points reach 11 firstly, we say he/she has won a set of game, and they will start the next set. However, the rules are a little strange: the loser would start the new set of game with the points that he/she has got in the last set. The one who wins 4 sets firstly becomes the final winner. For instance, we have their playing results in each round:

    A A A B B A A A B B A A A B A A

    where 'A' indicates Alice wins, and 'B' stands for Bob's winning. We can easily find that Alice has got 11 points, and Bob only wins 5. Therefore, Alice is the winner of this set, but the next set of game will start with 0 : 5, where Bob leads the game by 5 points.

    Given all their results in each round, you're required to find who wins the game finally. Note that the game may ends before we goes along all the given results.

    Input Format

     

    An integer T(T50) 
    will exist in the first line of input, indicating the number of test cases.

    Each test case is a string which contains only letter 'A' or 'B'. The length of each string will not exceed 10000.

    The test data guarantees that the winner always exists.

    Output Format

     

    Output 'Alice' if Alice wins, otherwise output 'Bob'.

    Sample Input

     
    1
    AAAAAAAAAAABBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBB
     

    Sample Output

     
    Alice

    第一天大一排位赛的第一题,水题一道直接贴代码

     1 #include<iostream>
     2 
     3 using namespace std;
     4 
     5 int main()
     6 {
     7     int t;
     8     long alice_win,bob_win,alice_point,bob_point;
     9     char result[10050];
    10 
    11     cin>>t;
    12 
    13     while(t--)
    14     {
    15         cin>>result;
    16         alice_win=bob_win=alice_point=bob_point=0;
    17         for(int i=0;i<=10000;i++)
    18         {
    19             if(result[i]=='A')
    20                 alice_point++;
    21             else if(result[i]=='B')
    22                 bob_point++;
    23             if(alice_point==11)
    24             {
    25                 alice_win++;
    26                 alice_point=0;
    27             }
    28             else if(bob_point==11)
    29             {
    30                 bob_win++;
    31                 bob_point=0;
    32             }
    33             if(alice_win==4)
    34             {
    35                 cout<<"Alice"<<endl;
    36                 break;
    37             }
    38             else if(bob_win==4)
    39             {
    40                 cout<<"Bob"<<endl;
    41                 break;
    42             }
    43         }
    44     }
    45 
    46     return 0;
    47 }
    [C++]
     
  • 相关阅读:
    现在, Delphi 的多线程已经非常易用了!
    发现 TSplitter 在嵌套时不好用, 索性写了个替代品
    关于显示透空歌词的思路 回复 "zhaoboaidelphi" 的问题
    简单获取钢琴 88 个键的音高频率值
    准备理一下菜单和工具栏相关的组件
    在 StringGrid 上画线时, 使用 GDI+ 以消除锯齿 回复 "gsjn_8888_6666" 的问题
    解压 svgz 到 svg
    jQuery能做到,PHP能做到,C#也能做到
    监测ASP.NET应用程序性能最简单的方法
    支持高并发的IIS Web服务器常用设置
  • 原文地址:https://www.cnblogs.com/lzj-0218/p/3181336.html
Copyright © 2011-2022 走看看