The number of walnuts
Time limit: 1.0s memory limit: 256.0MBProblem description
Xiao Zhang is a software project manager and he leads 3 development teams. The schedule is tight and it's working overtime today. To inspire morale, Xiao Zhang intends to send a sack of walnuts to each group (according to rumors Brain). His requirements are:
1. The number of walnuts in each group must be the same
2. Walnuts must be evenly divided within each group (not broken, of course)
3. Try to provide the minimum quantity to meet the conditions (save Revolution)
Input format input contains three positive integers a, B, C, indicating the number of people each group is working overtime, output a positive integer in a space-separated (a,b,c<30) output format, indicating the number of walnuts per bag. Sample Input 12 4 5 Sample output 120 Sample input 23 1 1 Sample output 23
Least common multiple, not explained.
AC Code:
/*************************************************************************> File name:e.cpp> Author:zzuspy > Mail: [email protected] > Created time:2014 December 03 Wednesday 19:20 35 seconds ********************************************** /#include <cstdio> #include <cstring> #include <iostream> #include < algorithm> #include <cstdlib> #include <cmath> #include <stack> #include <queue> #define LL Long Long#define max3 (a,b,c) max (A,max (b,c)) #define MIN3 (a,b,c) min (a,min (b,c)) using namespace Std;int gcd (int a, int b) { return b = = 0? A:GCD (b, a%b);} int main () {int A, B, C;while (scanf ("%d%d", &a, &b, &c)!=eof) {a = A*B/GCD (b); a = A*C/GCD (a,c);p rintf ("%d ", a);} return 0;}
Blue Bridge Cup-number of walnuts