Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++

Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++

 

 

#include<stdio.h>
int main()
{
    long long n,k,a,b,i;
	char x='G',y='B';
	int num=0;
	scanf("%I64d%I64d%I64d%I64d",&n,&k,&a,&b);
	if(a>b)
	{
		int t=a;a=b;b=t;
		char z=x;x=y;y=z;
	}
	if(b>(a+1)*(k)) {
		printf("NO\n");
		return 0;
	}
	for(i=0;i<n;i++){
		if(b>a&&num<k){printf("%c",y);b--;num++;}
		else {printf("%c",x);a--;num=0;}
	}
	return 0;
}
(Visited 128 times, 1 visits today)
By | 2017-04-07T22:11:46+00:00 January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , |0 Comments

About the Author:

Leave A Comment