#include <bits/stdc++.h>
using namespace std;
int main(){
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int t; cin >> t;
while(t--){
int n, k; cin >> n >> k;
if((k == 1 && n > 2) || (k == 2 && n > 4) || (k == 3 && n > 8)){cout << "NIE\n"; continue;}
if(n == 7 && k == 3) {cout << "AAAPAPP\n"; continue;}
if(n == 8 && k == 3) {cout << "AAAPAPPP\n"; continue;}
else if(n <= 8){
for(int i = 1; i <= k; i++) cout << 'A';
for(int i = k + 1; i <= n; i++) cout << 'P';
cout << '\n'; continue;
}
for(int i = 1; i <= k; i++) cout << 'A';
string s = "PAPPAA";
int am = 0, ind = 0;
while(am < n - k){
cout << s[ind%6];
am++; ind++;
}
cout << '\n';
}
return 0;
}
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(){ std::ios_base::sync_with_stdio(0); std::cin.tie(0); int t; cin >> t; while(t--){ int n, k; cin >> n >> k; if((k == 1 && n > 2) || (k == 2 && n > 4) || (k == 3 && n > 8)){cout << "NIE\n"; continue;} if(n == 7 && k == 3) {cout << "AAAPAPP\n"; continue;} if(n == 8 && k == 3) {cout << "AAAPAPPP\n"; continue;} else if(n <= 8){ for(int i = 1; i <= k; i++) cout << 'A'; for(int i = k + 1; i <= n; i++) cout << 'P'; cout << '\n'; continue; } for(int i = 1; i <= k; i++) cout << 'A'; string s = "PAPPAA"; int am = 0, ind = 0; while(am < n - k){ cout << s[ind%6]; am++; ind++; } cout << '\n'; } return 0; } |
English