# Unalike Gcd & Lcm Practice Coding Problem - CodeChefUnalike

define pb push_back
define ppb pop_back
define mp make_pair
typedef long long int lld;
using namespace std;
//int lim = 1000000000;
int lim = 31623;
vectorprimes;

void cal_primes(){
vectorisPrime(lim+1, true);
for(int i=2; i*i<=lim; i++){
if(isPrime[i]){

``````		for(int j=i*i; j<=lim; j+=i){
isPrime[j] = false;
}
}
}
for(int i=2; i<lim; i++){
if(isPrime[i])primes.pb(i);
}
//for(auto it:primes)cout<<it<<endl;
``````

}

vector<pair<int, int>> divisors(int x){

``````vector<pair<int, int>> res;
//cout<<primes.size()<<endl;
for(int i=0; i<primes.size(); i++){
int c = 0;
if(x<=primes[i])break;
//cout<<primes[i]<<" ";
if(x%primes[i] == 0){
while(x%primes[i] == 0){
c += 1;
x = x/primes[i];
}
}
if(c>0)
res.pb(mp(primes[i], c));

}
if(x!=1)res.pb(mp(x, 1));
``````

return res;
}

int solve(int x, int p){
int res=1;
vector<pair<int, int>>div = divisors(x);
//cout<<“div”<<endl;
//for(auto it:div)cout<<it.first<<" "<<it.second<<endl;
if(p==1)return res;
for(auto it:div){
if(it.second%p == 0){
res*=2;
}
}
return res;
}

int main(){
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
cal_primes();

``````int test;
cin>>test;

while(test--){
int x, q, p;
cin>>x>>q;

while(q--){
cin>>p;
cout<<solve(x, p)<<endl;

}
}
``````

return 0;
}
please someone see my code and tell me on which testcase is it giving tle error and also tell me the reason please.