-
Notifications
You must be signed in to change notification settings - Fork 0
/
codechef - lucky number game.cpp
71 lines (62 loc) · 1.25 KB
/
codechef - lucky number game.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
#include<bits/stdc++.h>
using namespace std;
const int sz = 2e5+10;
int arr[sz];
int a, b, n, t, ai;
int lcm, alicecount, bobcount, lcmcount;
bool bobwins;
int getLcm(int a, int b)
{
int gcd = __gcd(a, b);
return a*b/gcd;
}
int main()
{
//freopen("_in.txt", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
while(t--)
{
cin >> n >> a >> b;
lcm = getLcm(a, b);
alicecount = bobcount = lcmcount = 0;
for(int i=0; i<n; i++)
{
cin >> ai;
if(ai%a==0) bobcount++;
else if(ai%b==0) alicecount++;
// if(ai%lcm==0)
// {
// lcmcount++;
// }
// else if(ai%a==0)
// {
// bobcount++;
// }
// else if(ai%b==0)
// {
// alicecount++;
// }
}
//bobcount += (lcmcount%2);
if(bobcount>alicecount)
{
bobwins = true;
}
else
{
bobwins = false;
}
if(bobwins)
{
cout << "BOB";
}
else
{
cout << "ALICE";
}
cout << "\n";
}
return 0;
}