Last active
August 29, 2015 14:15
-
-
Save akouryy/bbc072a5cae7f252e921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define times(n, i) uptil(0, n, i) | |
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f); i <= _##i; i++) | |
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f); i < _##i; i++) | |
#define downto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f); i >= _##i; i--) | |
#define downtil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f); i > _##i; i--) | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(true) | |
int main(){ | |
int N, K; | |
scanf("%d %d", &N, &K); | |
K--; | |
string pyon = ""; | |
downto(N, 0, i){ | |
if(i == 0) | |
pyon += 'J'; | |
else | |
if((K >> (i - 1)) & 1) | |
pyon += string(1 << (i - 1), 'I'); | |
else{ | |
pyon += string(1 << (i - 1), 'J') + string(1 << (i - 1), 'O'); | |
break; | |
} | |
} | |
printf("%s\n", pyon.c_str()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment