标签:style blog io color os sp div on log
直接上递归版gcd模板,直接while的话效率更高~
1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 5 int gcd(int a, int b) { 6 return a % b ? gcd(b, a % b) : b; 7 } 8 9 int main() { 10 int a, b; 11 while(cin >> a >> b) { 12 int c = gcd(a, b); 13 cout << a / c * b << endl; 14 } 15 return 0; 16 }
标签:style blog io color os sp div on log
原文地址:http://www.cnblogs.com/bigbigsunrise/p/4063454.html