-
Notifications
You must be signed in to change notification settings - Fork 6
/
mishki playing games.cpp
76 lines (70 loc) · 953 Bytes
/
mishki playing games.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
70
71
72
73
74
75
76
#include <stdio.h>
int l2(int v)
{
int r=0;
if(v & 0xFFFF0000)
{
v >>=16;
r = 16;
}
if(v & 0xFF00)
{
v >>=8;
r |= 8;
}
if(v & 0xF0)
{
v >>=4;
r |= 4;
}
if(v & 0xC)
{
v >>=2;
r |= 2;
}
if(v & 0x2)
{
v >>=1;
r |= 1;
}
return r;
}
int main() {
// your code goes here
int n,q,a[1000000],l,r,i,j,temp,ans;
scanf("%d%d",&n,&q);
for(i=0;i<n;++i)
{
scanf("%d",&a[i]);
//a[i]= (log(a[i])/log(2)) +1;
}
while(q--)
{
scanf("%d%d",&l,&r);
l--;
r--;
j=0;
for(i=l;i<=r;++i)
{
if(a[i]>0)
{
a[i]= l2(a[i]) +1;
printf("%d ",a[i]);
//cout<<a[i]<<" ";
//a[i]= (log(a[i])/log(2)) +1;
a[i]=-a[i]; //to keep track of visited elements
}
j= j+a[i];
}
j=-j;
if(j%2!=0)
{
printf("Mishki\n");
}
else
{
printf("Hacker\n");
}
}
return 0;
}