//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
using i128=__int128_t;
void die(string S){puts(S.c_str());exit(0);}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n>>k;
if(n==k)
cout<<string(n,'A')<<'\n';
else if(n==k+1)
cout<<("A"+string(n-1,'P'))<<'\n';
else if(k>=4)
{
string pat="A"+string(k-2,'P')+string(k-2,'A')+"P";
for(int i=0;i<n;i++)
cout<<pat[i%sz(pat)];
cout<<'\n';
}
else if(k*2>=n)
cout<<string(n-k,'A')+string(k,'P')<<'\n';
else if(k==3&&n==7)
cout<<"AAAPAPP\n";
else if(k==3&&n==8)
cout<<"AAAPAPPP\n";
else
cout<<"NIE\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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | //Author: Kevin #include<bits/stdc++.h> //#pragma GCC optimize("O2") using namespace std; #define pb emplace_back #define mp make_pair #define ALL(x) (x).begin(),(x).end() #define rALL(x) (x).rbegin(),(x).rend() #define srt(x) sort(ALL(x)) #define rev(x) reverse(ALL(x)) #define rsrt(x) sort(rALL(x)) #define sz(x) (int)(x.size()) #define inf 0x3f3f3f3f #define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin()) #define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin()) #define uni(v) v.resize(unique(ALL(v))-v.begin()) using ll=long long; using ull=unsigned long long; using pii=pair<int,int>; using i128=__int128_t; void die(string S){puts(S.c_str());exit(0);} int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin>>t; while(t--) { int n,k; cin>>n>>k; if(n==k) cout<<string(n,'A')<<'\n'; else if(n==k+1) cout<<("A"+string(n-1,'P'))<<'\n'; else if(k>=4) { string pat="A"+string(k-2,'P')+string(k-2,'A')+"P"; for(int i=0;i<n;i++) cout<<pat[i%sz(pat)]; cout<<'\n'; } else if(k*2>=n) cout<<string(n-k,'A')+string(k,'P')<<'\n'; else if(k==3&&n==7) cout<<"AAAPAPP\n"; else if(k==3&&n==8) cout<<"AAAPAPPP\n"; else cout<<"NIE\n"; } return 0; } |
English