#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
string solve(int n, int k) {
if (n >= 3 && n <= 4 && k <= 1) return "NIE";
if (n >= 5 && n <= 8 && k <= 2) return "NIE";
if (n >= 9 && k <= 3) return "NIE";
if (n == 4 && k == 2) return "AAPP";
if (n == 8 && k == 3) return "AAAPAPPP";
string s(k, 'A');
while (int(s.size()) < n) s += "PAPPAA";
return s.substr(0, n);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int tc; cin >> tc;
while (tc--) {
int n, k;
cin >> n >> k;
cout << solve(n, k) << '\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 | #include <bits/stdc++.h> using namespace std; using i64 = long long; string solve(int n, int k) { if (n >= 3 && n <= 4 && k <= 1) return "NIE"; if (n >= 5 && n <= 8 && k <= 2) return "NIE"; if (n >= 9 && k <= 3) return "NIE"; if (n == 4 && k == 2) return "AAPP"; if (n == 8 && k == 3) return "AAAPAPPP"; string s(k, 'A'); while (int(s.size()) < n) s += "PAPPAA"; return s.substr(0, n); } int main() { cin.tie(0)->sync_with_stdio(0); int tc; cin >> tc; while (tc--) { int n, k; cin >> n >> k; cout << solve(n, k) << '\n'; } } |
English