#include <bits/stdc++.h>
using namespace std;
int main()
{
string ans[] = {
"",
"PA",
"PPAA",
"PPPAPAAA"
};
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t; cin >> t;
while (t--) {
int n, k; cin >> n >> k;
string res = "";
if (k <= 3) {
if (ans[k].length() < n) {
cout << "NIE\n";
continue;
}
res = ans[k];
}
else {
res = string(k, 'P');
while (res.length() < n) res += "AAPAPP";
}
cout << res.substr(0, n) << "\n";
}
}
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 | #include <bits/stdc++.h> using namespace std; int main() { string ans[] = { "", "PA", "PPAA", "PPPAPAAA" }; ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n, k; cin >> n >> k; string res = ""; if (k <= 3) { if (ans[k].length() < n) { cout << "NIE\n"; continue; } res = ans[k]; } else { res = string(k, 'P'); while (res.length() < n) res += "AAPAPP"; } cout << res.substr(0, n) << "\n"; } } |
English