基础 [cpp] view plain copy int gcd(int a,int b) { int r; while(b>0) { r=a%b; a=b; b=r; } return a; } 位运算 [cpp] view plain copy int gcd(int a,int b) { while(b^=a^=b^=a%=b); return a; } 递归 [cpp] view plain copy int gcd(int a,int b) { return (b>0)?gcd(b,a%b):a; } 基础 [cpp] view plain copy int gcd(int a,int b) { int r; while(b>0) { r=a%b; a=b; b=r; } return a; } 位运算 [cpp] view plain copy int gcd(int a,int b) { while(b^=a^=b^=a%=b); return a; } 递归 [cpp] view plain copy int gcd(int a,int b) { return (b>0)?gcd(b,a%b):a; }