-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game Of Deletion - Bit Magic (HackerEarth)
71 lines (70 loc) · 1.22 KB
/
Game Of Deletion - Bit Magic (HackerEarth)
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
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{
int n;
cin >> n;
int bits[33]={0};
ll reward1=0,count1=0;
ll reward2=0,count2=0;
for(int i=0;i<n;i++)
{
ll p;
cin >> p;
count1+=p;
int bit_no=0;
while(p>0)
{
if(p%2==1)
{
bits[bit_no]=1;
}
p/=2;
bit_no++;
}
}
for(int i=0;i<33;i++)
{
if(bits[i])
reward1+=(ll)(1<<i);
}
for(int i=0;i<33;i++)bits[i]=0;
for(int i=0;i<n;i++)
{
ll p;
cin >> p;
count2+=p;
int bit_no=0;
while(p>0)
{
if(p%2==1)
{
bits[bit_no]=1;
}
p/=2;
bit_no++;
}
}
for(int i=0;i<33;i++)
{
if(bits[i])
reward2+=(ll)(1<<i);
}
reward1=count1-reward1;
reward2=count2-reward2;
if(reward1>reward2)
{
cout<<1<<' '<<abs(reward1-reward2);
}
else if(reward1<reward2)
{
cout<<2<<" "<<abs(reward1-reward2);
}
else
{
cout<<1<<'\n';
}
return 0;
}