最大公約數(greatest common divisor,簡寫爲gcd;或highest common factor,簡寫爲hcf)
__gcd(x,y)是algorithm庫中的函數
#include<cstdio> #include<algorithm> using namespace std; int n,m; int main() { scanf("%d %d",&n,&m); int k=__gcd(n,m);//最大公約數 printf("%d",k); return 0; }spa