zoukankan      html  css  js  c++  java
  • cdoj 24 8球胜负(eight) 水题

    8球胜负(eight)

    Time Limit: 20 Sec  Memory Limit: 256 MB

    题目连接

    http://acm.uestc.edu.cn/#/problem/show/24

    Description

    8球是一种台球竞赛的规则。台面上有7个红球、7个黄球以及一个黑球,当然还有一个白球。对于本题,我们使用如下的简化规则:红、黄两名选手轮流用白球击打各自颜色的球,如果将该颜色的7个球全部打进,则这名选手可以打黑球,如果打进则算他胜。如果在打进自己颜色的所有球之前就把黑球打进,则算输。如果选手不慎打进了对手的球,入球依然有效。
    现在给出打进的球(白球除外)的顺序,以及黑球由哪方打进,你的任务是判定哪方是胜者。
    假设不会有一杆同时打进一颗黑球和其他彩球。

    Input

    输入包含多组数据。每组数据第一行是一个整数N(1≤N≤15),表示打进的球的个数,N=0表示结束。随后有一行,包含N个字符,依序表示打进的是何种球。如果是B,表示是红方打进的黑球,如果是L,表示是黄方打进的黑球。如果是Y则表示是黄球,R表示红球。字符间没有空格。

    所有输入都满足如下条件:最后一颗球打进时这局比赛正好结束,而且打进的红球和黑球都不超过7个。

    Output

    对每组数据,输出一行。如果红方胜,输出Red;黄方胜,输出Yellow。

    Sample Input

    5
    RYRRB
    9
    RRRRYRRRB

    Sample Output

    Yellow
    Red

    HINT

    题意

    题解:

    水题

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define test freopen("test.txt","r",stdin)  
    #define maxn 200000
    #define mod 10007
    #define eps 1e-9
    int Num;
    char CH[20];
    const int inf=0x3f3f3f3f;
    const ll infll = 0x3f3f3f3f3f3f3f3fLL;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    //**************************************************************************************
    
    int n;
    int flag;
    char s[maxn];
    int main()
    {
        //test;
        while(cin>>n)
        {
            if(n==0)
                break;
            flag=0;
            int flag1=0;
            int flag2=0;
            scanf("%s",s+1);
            for(int i=1;i<=n;i++)
            {
                if(s[i]=='Y')
                    flag2++;
                else if(s[i]=='R')
                    flag1++;
                else if(s[i]=='B')
                {
                    if(flag1==7)
                        flag=1;
                    else
                        flag=2;
                }
                else 
                {
                    if(flag2==7)
                        flag=2;
                    else
                        flag=1;
                }
            }
            if(flag==1)
                cout<<"Red"<<endl;
            else
                cout<<"Yellow"<<endl;
        }
    }
  • 相关阅读:
    编译错误总结。
    9.7
    9.5
    9.6
    9.4
    9.3
    FutureTask取结果超时代码小测试
    java concurrent包常用类小结
    java Nio零散知识点整理
    java进阶教程unit_2java常用类(2)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4544880.html
Copyright © 2011-2022 走看看