首页 > 其他 > 详细

D. Green and Black Tea

时间:2017-01-07 01:03:27      阅读:169      评论:0      收藏:0      [点我收藏+]

先搞多的,搞到相等。

(tmd上星期+上上星期简直是弱智,怎么也不会写,总是想着各种a/b,,,踢蹬)

#include<bits/stdc++.h>
#define lowbit(x) x&(-x) 
#define LL long long 
#define N 200005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
    int 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;
}
bool ans[N];
int cnt;
int main()
{
    int n=ra(),k=ra(),a=ra(),b=ra();
    bool last=0;
    int nn=n;
    if (a>b) last=1; 
    int tot=0;
    while (n--)
    {
        if (tot<k)
        {
            if (a>b) tot++,a--,ans[++cnt]=1,last=1;
                else tot++,b--,ans[++cnt]=0,last=0;
            if (a==b) break;
        }
        else 
        {
            if (last) ans[++cnt]=0,last^=1,b--;
                else ans[++cnt]=1,last^=1,a--;
            tot=0;
        }
        if (a<0 || b<0)
        {
            cout<<"NO";
            return 0;
        }
    }
    for (int i=1; i<=n; i++)
        if (last) ans[++cnt]=0,last^=1;
            else ans[++cnt]=1,last^=1;
    for (int i=1; i<=nn; i++)
        if (ans[i]) cout<<"G";
            else cout<<"B";
    return 0;
}
//原来死都做不出来,看起来是淡定啊。。。2333
//不知道怎么搞CSDN表示尴尬2333 

 

D. Green and Black Tea

原文:http://www.cnblogs.com/ccd2333/p/6257726.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!