Finding LCM LightOJ - 1215 (水题)

时间:2022-06-03 04:04:12

这题和这题一样。。。。。。只不过多了个数。。。

Finding LCM

LightOJ - 1215

https://www.cnblogs.com/WTSRUVF/p/9316412.html

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(a, n) for(int i=1; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
LL gcd(LL a, LL b)
{
return b==?a:gcd(b, a%b);
} int main()
{
int T, kase = ;
cin>> T;
while(T--)
{
LL a, b, L;
cin>> a >> b >> L;
printf("Case %d: ", ++kase);
LL c = a * b / gcd(a, b);
if(L % c)
{
cout<< "impossible" <<endl;
continue;
}
LL d = L / c;
while(gcd(c, d) != )
{
LL m = gcd(c, d);
c /= m;
d *= m;
}
cout<< d <<endl;
} return ;
}