最小公倍数和最大公约数 Posted on 2014-09-02 | Edited on 2019-02-04 | Comments: 1234567891011121314151617181920212223242526272829303132333435long long com_mul(long long n1,long long n2){ long long ans=n1*n2; long long i=2,limit=sqrt((double)min(n1,n2))+1; while(i<=n1&&i<=n2&&i<=limit) { if(n1%i==0&&n2%i==0) { ans/=i; n1/=i; n2/=i; } else i++; } return ans;}long long com_factor(long long n1,long long n2){ long long ans=1; long long i=2,limit=sqrt((double)min(n1,n2))+1; while(i<=n1&&i<=n2&&i<=limit) { if(n1%i==0&&n2%i==0) { ans*=i; n1/=i; n2/=i; } else i++; } return ans;}