You are viewing a single comment's thread. Return to all comments →
int getTotalX(vector a, vector b) { int gcd(int a,int b) { if(a==0) return b; return gcd(b%a,a); }
int lcm=a[0],hcf=b[0],ans=0; for( auto l:a) lcm=(lcm*l)/(gcd(l,lcm)); for(auto m:b) hcf=gcd(hcf,m); for(int i=1;i>=0;i++) {if((i*lcm)>hcf) break; if((hcf%(i*lcm))==0) ans++; } return ans;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
> a sweet and simple ans
int getTotalX(vector a, vector b) { int gcd(int a,int b) { if(a==0) return b; return gcd(b%a,a); }
}