The number of previous questions PREV-1 walnut

Problem Description
Zhang is a software project manager, he led three development groups. Tight schedule today in overtime it. To boost morale, Zhang intends to send a bag of walnuts (rumored to be able to nourish the brain) to each group. His requirements are:

  1. Number of walnuts each group must be the same

  2. Each group must be equally Walnut (of course, not broken)

  3. Try to provide a minimum number satisfying the condition of 1 (saving revolution Well)

Input format
input contains three positive integers a, b, c, represents the number of each group is overtime, separated by a space (a, b, c <30 )
output format
output a positive integer representing the number of bag walnut.
Sample Input 1
2. 4. 5
Sample Output 1
20 is
a sample input 2
. 3. 1. 1
Sample Output 2
. 3

#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(a%b==0){
		return b;
	}else{
		gcd(b,a%b);
	}
}

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int m = a*b/gcd(a,b);
	cout<<m*c/gcd(m,c);
	return 0;
}

Summary: The two concepts of the least common multiple [a, b] and the relationship between the greatest common divisor (a, b) a * b = (a, b) * [a, b]

Published 45 original articles · won praise 5 · Views 4186

Guess you like

Origin blog.csdn.net/Chuang98/article/details/103963341