标签:水
2 3 2 4
GBBG BGGB
注意换行。。。
代码:
#include <cstdio> #include <cstring> const int M = 33000; int s[M<<1]; void f(int n, int m){ int t, i, j; j = 0; for(i = 0; i < n; i ++){ int cou = 0; while(cou < m){ if(s[j] == 0) ++cou; if(cou >= m) break; j ++; if(j == 2*n) j = 0; } s[j] = 1; } } int main(){ int n, m; while(scanf("%d%d", &n, &m) == 2){ memset(s, 0, sizeof(s)); f(n, m); int i; for(i = 0; i < 2*n; i ++){ if(i&&i%50 == 0) printf("\n"); printf("%c", s[i]?'B':'G'); } printf("\n\n"); } return 0; }
标签:水
原文地址:http://blog.csdn.net/shengweisong/article/details/41594089