fork download
  1.  
  2. #include <stdio.h>
  3.  
  4. int table[1000][1000];
  5. int idx = 65;
  6.  
  7. int idk(a, b) {
  8. if(b == 0) return a;
  9. return gcd(b, a % b);
  10. }
  11.  
  12. void gcd(int a, int b, int x, int y) {
  13. if (a == 0 || b == 0) return;
  14.  
  15. int s = a < b ? a : b;
  16.  
  17. for (int i = x; i < x + s; i++)
  18. for (int j = y; j < y + s; j++)
  19. table[i][j] = idx;
  20.  
  21. idx++;
  22.  
  23. if (a < b)
  24. gcd(a, b - s, x + s, y);
  25. else
  26. gcd(a - s, b, x, y + s);
  27. }
  28.  
  29. int main() {
  30. int a, b;
  31. scanf("%d %d", &b, &a);
  32.  
  33. gcd(a, b, 0, 0);
  34.  
  35. for (int i = 0; i < b; i++) {
  36. for (int j = 0; j < a; j++)
  37. printf("%c", (char)table[i][j]);
  38. printf("\n");
  39. }
  40.  
  41. printf("%d\n", idk(a, b));
  42.  
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 5348KB
stdin
13 8
stdout
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
AAAAAAAA
BBBBBCCC
BBBBBCCC
BBBBBCCC
BBBBBDDE
BBBBBDDF
1