http://codeforces.com/contest/746/problem/D

首先说下一定是NO的情况。

假设a > b

那么,b最多能把a分成b + 1分,如果每份刚好是k的话,那么就最多能支持a的最大值是(b + 1) * k

其实就好比如,分成3分的话,x1 + x2  + x3 = m,每个xi <= k的,那么最多就是3 * k了。

所以判定下后,

后面的,如果a多,就用a,(注意不能超过k个)

b多,用b。一路模拟。

因为已经保证有解了,所以模拟后就是答案。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
void pr(int k, char ch) {
for (int i = ; i <= k; ++i) {
printf("%c", ch);
}
}
void work() {
int n, k, a, b;
scanf("%d%d%d%d", &n, &k, &a, &b);
if ((LL)k * (min(a, b) + ) < max(a, b)) {
cout << "NO" << endl;
return;
}
int to = ;
int has = ;
if (a > b) {
while (to < n) {
if (a > b && has < k) {
printf("G");
has++;
a--;
to++;
} else {
printf("B");
b--;
has = ;
to++;
}
}
} else {
while (to < n) {
if (b > a && has < k) {
printf("B");
has++;
to++;
b--;
} else {
printf("G");
has = ;
to++;
a--;
}
}
}
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
work();
return ;
}

最新文章

  1. 父子页面之间元素相互操作(iframe子页面)
  2. acm入门 杭电1001题 有关溢出的考虑
  3. webService-cxf
  4. WebAPI的初步认识(CURD)
  5. CruiseControl.NET/CCNET安装包下载
  6. Javascript算术运算
  7. bootstrap-4
  8. 数据库知识整理&lt;三&gt;
  9. 深入理解BootStrap之栅格系统(布局)
  10. Git 基础应用
  11. AndroidUI组件之ActionBar--基于下拉的导航方式
  12. Oracle游标
  13. 201521123093 java 第十二周学习总结
  14. java中自动装箱带来的性能问题
  15. GeoJSON C#判断某一点是否在某一区域范围之内
  16. MySQL数据库学习三 数据库对象和基本操作
  17. html与ios交互方法 WebViewJavascriptBridge
  18. 合肥工业大学oj p1012
  19. SpringBoot的学习【6.YML 和 Properties 的语法】
  20. 深入理解Redis复制

热门文章

  1. JAVA学习第六十四课 — 反射机制
  2. Xcode The identity used to sign the executable is no longer valid. 错误解决
  3. Android之键盘监听的执行机理【看清键盘监听的本质】【入门版】
  4. 关于集成支付宝SDK的开发
  5. win10访问共享文件夹提示:引用的账户当前已锁定,且当前可能无法登陆
  6. java定时器2-spring实现
  7. HDU2819 Swap —— 二分图最大匹配
  8. web项目开发 之 前端规范 --- HTML编码规范
  9. 并不对劲的bzoj4825:loj2018:p3721:[HNOI2017]单旋
  10. 虚拟机C盘扩容