最小公倍数
#include<iostream> using namespace std; int gcd(int a, int b) { while (b) { int t = a%b; a = b; b = t; } return a; } int lcm(int a, int b) { return a / gcd(a, b)*b; } int main() { ios::sync_with_stdio(false); int a, b; while (cin >> a >> b) cout << lcm(a, b) << ‘\n‘; return 0; }
时间: 2024-10-17 16:49:20