Skip to content

Instantly share code, notes, and snippets.

@akouryy
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akouryy/bbc072a5cae7f252e921 to your computer and use it in GitHub Desktop.
Save akouryy/bbc072a5cae7f252e921 to your computer and use it in GitHub Desktop.
#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