-
Notifications
You must be signed in to change notification settings - Fork 5
/
UVA-213.cpp
61 lines (57 loc) · 802 Bytes
/
UVA-213.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<cstring>
#include<cstdio>
#define MAXN 10
#define MAXM 1000
char s[MAXM];
char arr[MAXN][MAXM];
bool getString() {
char * p;
while(1) {
p = gets(s);
if(p == NULL)
return false;
if(strlen(s) != 0)
break;
}
int n = 1, len = strlen(s), i = 0, j;
while(i < len) {
for(j=0; j<((1<<n)-1); ++j) {
arr[n][j] = s[i++];
if(i >= len)
break;
}
++n;
}
return true;
}
int func(int n) {
int i = 0;
char c;
while(n > 0) {
scanf("%c", &c);
if(c != '0' && c != '1')
continue;
--n;
i *= 2;
if(c == '1')
i += 1;
}
return i;
}
int main() {
int len, a;
while(getString()) {
while(1) {
len = func(3);
if(len == 0)
break;
while(1) {
a = func(len);
if(a == (1<<len)-1)
break;
putchar(arr[len][a]);
}
}
puts("");
}
}