思路: lcm= a*b/gcd(a,b)
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #include<queue> #include<stack> #define mem(a,b) memset(a,b,sizeof(a)) #define ll __int64 #define MAXN 1000 #define INF 0x7ffffff #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 using namespace std; int gcd(int a,int b) { return a%b!=0?gcd(b,a%b):b; } int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d ",a*b/gcd(a,b)); } return 0; }