<pre name="code" class="cpp">//求x和y的最大公约数 x<y //辗转相除法O(log(n)) int susu(int x, int y) { if(x>y) { int t = x; x = y; y = t; } if(x==0) { return y; } return susu(y%x, x); } //暴力搜索O(n) int susu1(int x, int y) { if(x>y) { int t = x; x = y; y = t; } int result = 1; for(int i=1; i<=x ;i++) { if(x%i==0 && y%i==0) { result = i; } } return result; }