Untitled
1 week ago in Plain Text
#include<stdio.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
void dfs(long long int level, long long int l, long long int r);
char s1[5]="OuQ";
long long int len[55];
long long int k, l, r;
int main(void)
{
int i;
len[1]=3;
for(i=2; i<=50; i++)
len[i]=2*len[i-1]+3;
while(scanf("%lld %lld %lld", &k, &l, &r)!=EOF)
{
dfs(k, l, r);
printf("\n");
}

return 0;
}
void dfs(long long int level, long long int l, long long int r)
{
int i;

if(level==0)
return;
if(l==0)
printf("O");
if(l<len[level]/2 && r>0)
dfs(level-1, max(0, l-1), min(r, len[level-1])-1);
if(l<=len[level]/2 && len[level]/2<=r)
printf("u");
if(l<len[level]-1 && len[level]/2<r)
dfs(level-1, max(0, l-len[level]/2-1), min(r-len[level]/2, len[level-1])-1);
if(r==len[level]-1)
printf("Q");
}
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
35
36
37
38
39