Help me in solving HP18 problem

My issue

My code

#include <bits/stdc++.h>
using namespace std;
void solve(){
	int n,x,y;
	cin>>n>>x>>y;
	vector<int>v(n);
	int vb=0,va=0,vl=0;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int lc=max(x,y),lc_m=min(x,y);
	int ma=lc;
	while(lc%lc_m!=0){
		lc=lc+ma;
	}
	for(int i=0;i<n;i++){
		if(v[i]%x==0){
			vb++;
			
		}
		if(v[i]%y==0){
			va++;
		}
		if(v[i]%lc==0){
			vl++;
		}
	}
	if(lc%2==0){
		vb=vb-vl/2;
		va=va-vl/2;
	}
	else{
		vb=vb-vl/2+1;
		va=va-vl/2;
	}
	if(va<vb){
		cout<<"BOB"<<endl;
	}
	else{
		cout<<"ALICE"<<endl;
	}

}
int main()
{

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t;cin>>t;
	while(t--){
		solve();
	}
}

Problem Link: HP18 Problem - CodeChef