問題描述
小張是軟件項目經理,他帶領3個開發組。工期緊,今天都在加班呢。爲鼓舞士氣,小張打算給每個組發一袋核桃(據傳言能補腦)。他的要求是:
各組的核桃數量必須相同
各組內必須能平分核桃(當然是不能打碎的)
儘量提供滿足1,2條件的最小數量(節約鬧革命嘛)
輸入格式
輸入包含三個正整數a, b, c,表示每個組正在加班的人數,用空格分開(a,b,c<30)
輸出格式
輸出一個正整數,表示每袋核桃的數量。
樣例輸入1
2 4 5
樣例輸出1
20
樣例輸入2
3 1 1
樣例輸出2
3
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
int gcd(int a, int b) {
if (b == 0) return a;
else return gcd(b, a%b);
}
int main() {
int a, b, c;
cin >> a >> b >> c;
int temp = a*b / gcd(a, b);
int ans = temp*c / gcd(temp, c);
cout << ans << endl;
system("pause");
return 0;
}