Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include <functional>
- #include<string>
- #include<algorithm>
- #include <tuple>
- #include<random>
- #include <iomanip>
- #include<set>
- using namespace std;
- using ll = unsigned long long;
- int gcd(int a, int b) {
- return b ? gcd(b, a % b) : a;
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int n, m;
- cin >> n >> m;
- string s = "", u = "";
- int k = gcd(n, m);
- if (k == 1)cout << "NO";
- else {
- cout << "YES" << '\n';
- for (int j = 2; j <= k; ++j) {
- if (n % j == 0 && m % j == 0) {
- for (int i = 0; i < m; ++i) {
- if (!((i / j) % 2))s += 'B';
- else s += 'X';
- }
- for (char i : s) {
- if (i == 'B')
- u += 'X';
- else u += 'B';
- }
- for (int i = 0; i < n; ++i) {
- if (!((i / j) % 2))
- cout << s;
- else
- cout << u;
- if (i != n - 1)cout << '\n';
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment