Codeforces Round #392 (Div. 2), problem: (B) Blown Garland Solution in C/C++

[amazon_link asins=’0789751984,0321563840,0321776410,B00EJ4SQ36,0262162091,0321563840,0789751984,1534679707,0131103628,0321776410′ template=’ProductCarousel’ store=’eblogarithm-20′ marketplace=’US’ link_id=’79c02f8c-1c32-11e7-b0b4-817d87f7d431′]

 

#include <stdio.h>
#include <string.h>

int cnt(char *s, char c) {
int l, i, j, k;

l = strlen(s);
j = -1;
for (i = 0; i < l; i++)
if (s[i] == c) {
j = i % 4;
break;
}
k = 0;
for (i = j; i < l; i += 4)
if (s[i] == ‘!’)
k++;
return k;
}

int main() {
static char s[256];

scanf(“%s”, s);
printf(“%d %d %d %d\n”, cnt(s, ‘R’), cnt(s, ‘B’), cnt(s, ‘Y’), cnt(s, ‘G’));
return 0;
}

 

[amazon_link asins=’0789751984,0321563840,0321776410,B00EJ4SQ36,0262162091,0321563840,0789751984,1534679707,0131103628,0321776410′ template=’ProductCarousel’ store=’eblogarithm-20′ marketplace=’US’ link_id=’79c02f8c-1c32-11e7-b0b4-817d87f7d431′]

(Visited 256 times, 1 visits today)

About the Author:

Leave A Comment