Created
October 28, 2010 08:36
-
-
Save wasabili/650921 to your computer and use it in GitHub Desktop.
Poster
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 <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