/* -*- coding: utf-8 -*- * * 1732.cc: No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2) - yukicoder */ #include #include #include #include using namespace std; /* constant */ const int MAX_N = 200; const char S0[] = "ACCACCCCCCCCABACAAFFE"; // 05314531463146314527262527776 const char S1[] = "BBCCCFACAC"; // 013571463726254 const char S2[] = "CCBBA"; // 03145672 = 1100 1100 1011 1011 1010 /* typedef */ typedef vector vi; /* global variables */ /* subroutines */ void hex2oct(const char s[]) { vi hs, cs(8, 0); int l = strlen(s); for (int i = l - 1; i >= 0; i -= 3) { int x = 0; for (int d = 0; d < 3; d++) x |= (i >= d ? s[i - d] - 'A' + 10 : 0) << (d * 4); while (x > 0) { int h = x & 7; hs.push_back(h); cs[h]++; x >>= 3; } } reverse(hs.begin(), hs.end()); printf("%s -> ", S0); for (auto h: hs) printf("%d", h); putchar(' '); for (int i = 0; i < 8; i++) printf("%d", cs[i]); putchar('\n'); } /* main */ int main() { /* Let r=n%3, r == 0 -> |5,6,7|2,3,6,7|1,3,5,7|2,3,4,5,6,7| r == 1 -> |0|0|1|2,3,4,5,6,7| r == 2 -> |0|2,3|1,3,5,7|2,3,4,5,6,7| */ //hex2oct(S0); hex2oct(S1); hex2oct(S2); int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); int q = n / 3, r = n % 3; if (r == 0) { if (q % 7 != 0) { puts("-1"); continue; } int x = q / 7; while (x--) printf("%s", S0); putchar('\n'); } else if (r == 1) { if ((q * 4 + 2) % 7 != 0) { puts("-1"); continue; } int x = (n - 10) / 7; printf("%s", S1); while (x--) printf("%s", S0); putchar('\n'); } else { // r == 2 if ((q * 4 + 3) % 7 != 0) { puts("-1"); continue; } int x = (n - 5) / 7; printf("%s", S2); while (x--) printf("%s", S0); putchar('\n'); } } return 0; }