Benefit UVA - 11889
Benefit
题意: 给出a和c, 让求最小的b使得lcm(a, b) == c.
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int gcd(int a, int b){ 5 return b == 0 ? a : gcd(b, a % b); 6 } 7 int main(){ 8 int a, c; 9 int t; 10 scanf("%d", &t); 11 while(t--){ 12 scanf("%d %d", &a, &c); 13 if(c % a){ 14 puts("NO SOLUTION"); 15 }else{ 16 int b = c / a; 17 int g = gcd(a, b); 18 while(g != 1){ 19 b *= g; 20 a /= g; 21 g = gcd(a, b); 22 } 23 printf("%d\n", b); 24 } 25 } 26 }