Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
#ifdef _MSC_VER
#ifndef __GNUC__
#pragma warning(disable: 4996)
#endif
#define main main0
#endif
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
string intToBinary(int x) {
string s;
for(int i = 31; i >= 0; --i) {
s += (x & (1 << i)) ? '1' : '0';
}
return s;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/*for(int i = 4, i1; i < 10; ++i) {
i1 = 1;
cout << "s�owo d�ugo��: " << i << '\n';
for(int j = 1; j < i; ++j)
i1 *= 2;
--i1;
vector<string> slowo;
for(int k = 0, l; k < i1; ++k) { // kolejne wzorce
string s;
l = k;
for(int j = 0; j < i; ++j) { // string ze wzorca
s += (l & 1) == 1 ? 'A' : 'P';
l >>= 1;
}
slowo.push_back(s);
}
int dlugosc = i;
int j, j1;
for(int js = 0; js < slowo.size(); ++js) { // string z tablicy
for(j = i - 1; j > 0; --j) { // d�ugo�� podci�gu
string s1, s2;
for(j1 = 0; j1 <= i - j; ++j1) { // pocz�tek podci�gu
s1 = s2 = slowo[js].substr(j1, j);
reverse(s2.begin(), s2.end());
if(s1 == s2) { // palindrom
dlugosc = j;
break;
}
}
}
}
cout << " " << " podci�g d�ugo�ci " << dlugosc << " brak palindromu" << endl;
}*/
string s4("AAPP");
string s8("AAAPAPPP");
string s12("PAPPAAPAPPAA");
int t;
cin >> t;
for(int i = 0; i < t; ++i) {
int n, k;
cin >> n >> k;
if(k == 1) {
if(n < 3)
cout << s4.substr(1, n);
else
cout << "NIE";
} else if(k == 2) {
if(n < 5)
cout << s4.substr(0, n);
else
cout << "NIE";
} else if(k == 3) {
if(n < 9)
cout << s8.substr(0, n);
} else {
for(int j = 0; j < k; ++k)
cout << 'A';
for(n -= k; n > 12; n -= 12)
cout << s12;
cout << s12.substr(0, n);
}
cout << endl;
}
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #ifdef _MSC_VER #ifndef __GNUC__ #pragma warning(disable: 4996) #endif #define main main0 #endif #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; string intToBinary(int x) { string s; for(int i = 31; i >= 0; --i) { s += (x & (1 << i)) ? '1' : '0'; } return s; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); /*for(int i = 4, i1; i < 10; ++i) { i1 = 1; cout << "s�owo d�ugo��: " << i << '\n'; for(int j = 1; j < i; ++j) i1 *= 2; --i1; vector<string> slowo; for(int k = 0, l; k < i1; ++k) { // kolejne wzorce string s; l = k; for(int j = 0; j < i; ++j) { // string ze wzorca s += (l & 1) == 1 ? 'A' : 'P'; l >>= 1; } slowo.push_back(s); } int dlugosc = i; int j, j1; for(int js = 0; js < slowo.size(); ++js) { // string z tablicy for(j = i - 1; j > 0; --j) { // d�ugo�� podci�gu string s1, s2; for(j1 = 0; j1 <= i - j; ++j1) { // pocz�tek podci�gu s1 = s2 = slowo[js].substr(j1, j); reverse(s2.begin(), s2.end()); if(s1 == s2) { // palindrom dlugosc = j; break; } } } } cout << " " << " podci�g d�ugo�ci " << dlugosc << " brak palindromu" << endl; }*/ string s4("AAPP"); string s8("AAAPAPPP"); string s12("PAPPAAPAPPAA"); int t; cin >> t; for(int i = 0; i < t; ++i) { int n, k; cin >> n >> k; if(k == 1) { if(n < 3) cout << s4.substr(1, n); else cout << "NIE"; } else if(k == 2) { if(n < 5) cout << s4.substr(0, n); else cout << "NIE"; } else if(k == 3) { if(n < 9) cout << s8.substr(0, n); } else { for(int j = 0; j < k; ++k) cout << 'A'; for(n -= k; n > 12; n -= 12) cout << s12; cout << s12.substr(0, n); } cout << endl; } return 0; } |
English