Mephistopheles_

D

Mar 20th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include <functional>
  4. #include<string>
  5. #include<algorithm>
  6. #include <tuple>
  7. #include<random>
  8. #include <iomanip>
  9. #include<set>
  10. using namespace std;
  11. using ll = unsigned long   long;
  12. int gcd(int a, int b) {
  13.     return b ? gcd(b, a % b) : a;
  14. }
  15. int main() {
  16.     ios::sync_with_stdio(0);
  17.     cin.tie(0);
  18.     int n, m;
  19.     cin >> n >> m;
  20.     string s = "", u = "";
  21.     int k = gcd(n, m);
  22.     if (k == 1)cout << "NO";
  23.     else {
  24.         cout << "YES" << '\n';
  25.         for (int j = 2; j <= k; ++j) {
  26.             if (n % j == 0 && m % j == 0) {
  27.                 for (int i = 0; i < m; ++i) {
  28.                     if (!((i / j) % 2))s += 'B';
  29.                     else s += 'X';
  30.                 }
  31.                 for (char i : s) {
  32.                     if (i == 'B')
  33.                         u += 'X';
  34.                     else u += 'B';
  35.                 }
  36.                 for (int i = 0; i < n; ++i) {
  37.                     if (!((i / j) % 2))
  38.                         cout << s;
  39.                     else
  40.                         cout << u;
  41.                     if (i != n - 1)cout << '\n';
  42.                 }
  43.                 break;
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment