1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #include <iostream> #include <cmath> using namespace std; typedef long long LL; int T, n, k; LL l, r, s; int main() { scanf("%d", &T); while (T--) { scanf("%d%d", &n, &k); s = (LL) k * 2; l = sqrt(s); if (l * (l + 1) < s) ++l; r = k - (l * (l - 1) / 2 + 1); for (int i = 0; i < n - 1 - l; ++i) printf("a"); printf("b"); for (int i = n - l; i < n - 1 - r; ++i) printf("a"); printf("b"); for (int i = n - r; i < n; ++i) printf("a"); printf("\n"); } return 0; }
|