1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

string iter(int n, string pattern);

string draw(int N) {
  if (N == 0) {
    return "";
  } else if (N == 1) {
    return "AEC";
  }
  string res = iter(N, "A");

  int half = (N + 1) / 2;
  string row = iter(half, "E").append(iter(half - 1, "CA")).append("C");
  int odd = N & 1;
  string rhombus = iter(half - odd, row).append(iter(half, "E"));
  res.append(rhombus).append(draw(N - half));
  int rest = N - half + odd;
  if (rest == 1) {
    res.append("C");
  } else if (rest == 2) {
    res.append("CACEC");
  } else {
    res.append(iter(rest - 1, "CA"));
    res.append(iter(rest - 1, "CE"));
    res.append(draw(rest - 2));
    res.append("C");
  }
  return res;
}

void enumerate() {
  for (int i = 1; i < 200; ++i) {
    string res = draw(i);
    printf("%4d => %6lu:  %s\n", i, res.length(), res.substr(0, 150).c_str());
  }
  exit(0);
}

int main() {
  // enumerate();

  int N;
  scanf("%d", &N);
  string res = draw(N);

  printf("%s\n", res.c_str());

  // printf("%lu\n", res.length());
  // if (res.length() < 1000) {
  //   puts(res.c_str());
  // }
  return 0;
}

string iter(int n, string pattern) {
  if (n == 0 || pattern.length() == 0) {
    return "";
  }
  if (n == 1) {
    return pattern;
  }
  if (n <= 9) {
    bool multi = pattern.length() > 1;
    string ret = to_string(n);
    if (multi) {
      ret.append("[");
    }
    ret.append(pattern);
    if (multi) {
      ret.append("]");
    }
    return ret;
  }
  if (n == 10 && pattern.length() <= 3) {
    return iter(9, pattern).insert(0, pattern);
  }
  if (n <= 18 && pattern.length() == 1) {
    return iter(n - 9, pattern).append(iter(9, pattern));
  }
  for (int i = 9; i >= 2; --i) {
    if (n % i == 0) {
      string ret = to_string(i);
      ret.append("[").append(iter(n / i, pattern)).append("]");
      return ret;
    }
  }

  string alternative = iter(n - 1, pattern).append(pattern);
  string alt2 = iter(n - 5, pattern).append(iter(5, pattern));
  if (alt2.length() < alternative.length()) {
    alternative.assign(alt2);
  }

  string elem = pattern;
  string ret = "";
  while (n > 0) {
    ret.append(iter(n % 9, elem));
    n /= 9;
    elem = iter(9, elem);
  }

  if (ret.length() < alternative.length()) {
    return ret;
  } else {
    return alternative;
  }
}