zoukankan      html  css  js  c++  java
  • D. Green and Black Tea

    先搞多的,搞到相等。

    (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 
  • 相关阅读:
    C语言第一天
    【PHP学习笔记】Hello,World!
    Photoshop文本位置范围
    快捷套取单色图片
    cesium加载纽约市3dtiles模型
    Python基础——0前言
    Python基础——1基础
    Python基础——2函数
    Python基础——3特性
    Python基础——4高阶函数
  • 原文地址:https://www.cnblogs.com/ccd2333/p/6257726.html
Copyright © 2011-2022 走看看