按题意直接模拟即可。

AC code:

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n + 1], sums = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sums += a[i];
    }
    for (int i = 1; i <= n; i++) {
        if (a[i] * 5 <= sums) {
            for (int j = 1; j <= a[i]; j++) {
                cout << "A";
            }
            cout << endl;
        } else {
            for (int j = 1; j <= a[i]; j++) {
                cout << "B";
            }
            cout << endl;
        }
    }
    return 0;
}