Blue Bridge Cup-number of walnuts

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.