-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOLONY_2.cpp
69 lines (55 loc) · 973 Bytes
/
COLONY_2.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
62
63
64
65
66
67
68
69
#include <cstdio>
#include <cmath>
using namespace std;
long long inv;
inline void solve( long long len, long long post, long long year )
{
// printf("len = %lld, post = %lld, year = %lld, inv = %lld\n",len,post,year,inv);
if( len == 2 )
{
long long ret;
if( post == 1 )
ret = 1;
else
ret = 0;
if( inv & 1 )
{
if( ret == 1 )
ret = 0;
else
ret = 1;
}
// printf("ret = %lld\n",ret);
puts( !ret ? "red" : "blue" );
return;
}
else if( post > len/2 )
solve( len/2, post - len/2, year - 1 );
else
{
inv++;
solve( len/2 ,post ,year - 1 );
}
}
int main()
{
long long len, post, year, t, store[52];
store[0] = 1;
for( t = 1; t <= 51; t++ )
store[t] = 2 * store[t-1];
// printf("\n") ;
for( t = 1; t--; )
{
scanf("%lld %lld",&year,&post);
if( !year && !post )
{
printf("red\n");
continue;
}
len = store[year];
post++;
inv = 0;
solve( len, post, year );
}
return 0;
}