fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void fileIO() {
  6. #ifndef ONLINE_JUDGE
  7. freopen("input.txt", "r", stdin);
  8. freopen("output.txt", "w", stdout);
  9. #endif
  10.  
  11. #ifdef ONLINE_JUDGE
  12. #endif
  13. }
  14.  
  15. int TC;
  16.  
  17. void get_shit_done() {
  18. int n, k;
  19. cin >> n >> k;
  20.  
  21. if (not k) {
  22. for (int i = 0; i < n; ++i) {
  23. cout << "ABC";
  24. }
  25. return;
  26. }
  27.  
  28. if (k > 3 * n - 4) {
  29. cout << -1;
  30. return;
  31. }
  32.  
  33. while (k <= 3 * n - 7) {
  34. cout << "ABC";
  35. --n;
  36. }
  37.  
  38. if (k == 3 * n - 4) {
  39. for (int i = 0; i < n; ++i) {
  40. cout << "AB";
  41. }
  42. for (int i = 0; i < n; ++i) {
  43. cout << "C";
  44. }
  45. } else if (k == 3 * n - 5) {
  46. for (int i = 0; i < n - 1; ++i) {
  47. cout << "AB";
  48. }
  49. cout << "A";
  50. for (int i = 0; i < n; ++i) {
  51. cout << "C";
  52. }
  53. cout << "B";
  54. } else {
  55. for (int i = 0; i < n - 1; ++i) {
  56. cout << "AB";
  57. }
  58. for (int i = 0; i < n; ++i) {
  59. cout << "C";
  60. }
  61. cout << "AB";
  62. }
  63. }
  64.  
  65. signed main() {
  66. fileIO();
  67. cin.tie(nullptr);
  68. cout.tie(nullptr);
  69. ios::sync_with_stdio(false);
  70.  
  71. int T = 1;
  72. for (TC = 1; TC <= T; ++TC) {
  73. get_shit_done();
  74. }
  75.  
  76. return 0;
  77. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty