核桃的数量

这题求3个数的最小公倍数。

首先求a、b的最下公倍数p1,只有把p1给a、b,才可分。

然后求p1和c的最下公倍数。也就是把处理过的a、b看成一堆,用篇、p1表示他们。求出p2

答案就是p2 。

所以,用这个思路,可以求出n个数的最小公倍数。

#include <stdio.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>

#define I scanf
#define OL puts
#define O printf
#define F(a,b,c) for(a=b;a<c;a++)
#define FF(a,b) for(a=0;a<b;a++)
#define FG(a,b) for(a=b-1;a>=0;a--)
#define LEN 3000
#define MAX 0x06FFFFFF
#define V vector<int>

using namespace std;

int main(){
//    freopen("D:/CbWorkspace/blue_bridge/核桃的重量.txt","r",stdin);
    int a,b,c;
    I("%d%d%d",&a,&b,&c);
    int p1=a*b/__gcd(a,b);
    int p2=p1*c/__gcd(p1,c);
    O("%d
",p2);
    return 0;
}
原文地址:https://www.cnblogs.com/TQCAI/p/8643665.html