#include <cstdio> #define P(x) (1ll<<(x)) using namespace std; typedef long long LL; const char C[3][2] = {{'b', 'c'}, {'a', 'c'}, {'a', 'b'}}; LL n, k; int main() { scanf("%lld%lld", &n, &k); if (n <= 60 && k+3 > 3*P(n)) { puts("NIE"); } else { int div = P(n)-1; char c = 'a' + (k+div-1)/div - 1; putchar(c); k = (k-1)%div+1; bool start = false; for (LL i=P(60); i; i>>=1) { // printf("\n%lld\n", LL(k)); if (start) { c = C[c-'a'][bool(k&i)]; putchar(c); } else start = k&i; } putchar('\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 | #include <cstdio> #define P(x) (1ll<<(x)) using namespace std; typedef long long LL; const char C[3][2] = {{'b', 'c'}, {'a', 'c'}, {'a', 'b'}}; LL n, k; int main() { scanf("%lld%lld", &n, &k); if (n <= 60 && k+3 > 3*P(n)) { puts("NIE"); } else { int div = P(n)-1; char c = 'a' + (k+div-1)/div - 1; putchar(c); k = (k-1)%div+1; bool start = false; for (LL i=P(60); i; i>>=1) { // printf("\n%lld\n", LL(k)); if (start) { c = C[c-'a'][bool(k&i)]; putchar(c); } else start = k&i; } putchar('\n'); } return 0; } |