Need help in CHEFWM problem (starters 21)

need help and opinion on why my code is wrong for CHEFWM problem in starters 21,
link to question : CHEFWM Problem - CodeChef

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX 100001
vector prime;

void makeprime(){
vector isprime(MAX,true);
isprime[0]=isprime[1]=0;
for(ll i=2;i<MAX;i++){
if(isprime[i] == 1){
for(ll j=i*i;j<MAX;j+=i) isprime[j]=0;
}
}
for(ll i=0;i<MAX;i++){
if(isprime[i]) prime.push_back(i);
}
}

int main() {
// your code goes here
makeprime();

ll t;
cin>>t;

while(t--){
    ll n,m;
    cin>>n>>m;
    
   /* if(n==1){
        cout<<"1\n";
        continue;
    }*/
    if(m==1){
        cout<<"0\n";
        continue;
    } 
   
    ll ans=0;
    
    for(auto &it:prime){
        if(it>m) break;
        if((m%it) == 0){
            ans++;
       
        }
    }
    if(ans!=0){
        while((n%ans) != 0) ans--;
    }
    
    cout<<ans<<"\n";
    
}
return 0;

}

Prime numbers which are greater than 100001 are not included in your prime vector that’s why you got WA.
Approach – you only have to count the distinct prime factors
can refer this solution (CodeChef: Practical coding for everyone)