Skip to content

Instantly share code, notes, and snippets.

@wasabili
Created October 28, 2010 08:36
Show Gist options
  • Save wasabili/650921 to your computer and use it in GitHub Desktop.
Save wasabili/650921 to your computer and use it in GitHub Desktop.
Poster
#include <cstdio>
#include <string>
using namespace std;
string make(char x, int n){
string s;
for(int i=0;i<n;i++) s+=x;
return s;
}
string solve(int n, int l){
if(n==1) return string("J");
else if(l <= n/2) return make('J',n/2)+make('O',n/2);
else return make('I',n/2)+solve(n/2,l-n/2);
}
main(){
int n,l;
scanf("%d%d",&n,&l);
printf("%s\n", solve(1<<n,l).c_str());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment