int gcd(int v1,int v2) { while(v2) { int temp=v2; v2=v1%v2; v1=temp; } return v1; } 转载于:https://blog.51cto.com/jun0213/1048569