codeforces A. Little Artem

在这里插入图片描述

题目

题意:

你要构造一个序列满足 B = W + 1 B=W+1 其中 B B 代表的是周围有至少一个 W 'W' B 'B' 的总数量, W W 与之相反。(有单引号的代表是个字符)

思路:

感觉看起来挺复杂的,但是因为 B = W + 1 B=W+1 那么一个一个为 2 2 ,一个为 1 1 就可以解决了,所以只要有一个 W 'W' 在角落就行了。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void out(int x) {
    if (x > 9) out(x / 10);
    putchar(x % 10 + '0');
}
int main() {
    int n, m, t;
    read(t);
    while (t--) {
        read(n), read(m);
        int cnt = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (i == n && j == m) printf("W");
                else printf("B");
            }
            printf("\n");
        }
    }
    return 0;
}

发布了463 篇原创文章 · 获赞 27 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/weixin_45031646/article/details/105411638