1. 程式人生 > >51nod 1012 最小公倍數LCM

51nod 1012 最小公倍數LCM

輸入2個正整數A,B,求A與B的最小公倍數。  

輸入

2個數A,B,中間用空格隔開。(1<= A,B <= 10^9)

輸出

輸出A與B的最小公倍數。

輸入樣例

30 105

輸出樣例

210

程式碼:
#include <iostream>
#include <cstdio>
#include <cmath>
#define MAX 50000

using namespace std;
typedef long long ll;
int gcd(int a,int b) { while(b ^= a ^= b ^= a %= b); return a; } int main() { int a,b; scanf("%d%d",&a,&b); printf("%lld",(ll)a / gcd(a,b) * b); }