#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ve vector
#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
bool ispal(string s){
for(int i = 0; 2*i < s.size(); i++){
if(s[i] != s[s.size()-1-i])
return 0;
}
return 1;
}
void solve(){
int n, k;
cin >> n >> k;
string res1 = "AP", res2 = "AAPP", res3 = "AAAPAPPP";
string f = "PPAPAAPPAPAAPPAPAA";
if(k == 1){
if(n > 2){
cout << "NIE\n";
return;
}
cout << res1.substr(0, n) << "\n";
}
else if(k == 2){
if(n > 4){
cout << "NIE\n";
return;
}
cout << res2.substr(0, n) << "\n";
}
else if(k == 3){
if(n > 8){
cout << "NIE\n";
return;
}
cout << res3.substr(0, n) << "\n";
}
else{
string res(k, 'A');
for(int i = 0; i < n-k; i++)
res += f[i%f.size()];
cout << res << "\n";
}
// if(2*k < n){
// cout << "NIE\n";
// return;
// }
// cout << string(k, 'A') + string(n-k, 'P') << "\n";
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int T;
cin >> T;
while(T--){
solve();
}
}
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #include <bits/stdc++.h> using namespace std; #define ll long long #define ve vector #define fi first #define se second #define pb push_back #define all(x) begin(x), end(x) typedef pair<int, int> pii; typedef pair<ll, ll> pll; bool ispal(string s){ for(int i = 0; 2*i < s.size(); i++){ if(s[i] != s[s.size()-1-i]) return 0; } return 1; } void solve(){ int n, k; cin >> n >> k; string res1 = "AP", res2 = "AAPP", res3 = "AAAPAPPP"; string f = "PPAPAAPPAPAAPPAPAA"; if(k == 1){ if(n > 2){ cout << "NIE\n"; return; } cout << res1.substr(0, n) << "\n"; } else if(k == 2){ if(n > 4){ cout << "NIE\n"; return; } cout << res2.substr(0, n) << "\n"; } else if(k == 3){ if(n > 8){ cout << "NIE\n"; return; } cout << res3.substr(0, n) << "\n"; } else{ string res(k, 'A'); for(int i = 0; i < n-k; i++) res += f[i%f.size()]; cout << res << "\n"; } // if(2*k < n){ // cout << "NIE\n"; // return; // } // cout << string(k, 'A') + string(n-k, 'P') << "\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while(T--){ solve(); } } |
English