11889专题

uva 11889 Benefit(数学)

给出a,c,问是否存在一个尽可能小的数b使得lcm(a, b) == c 因为a*b/gcd(a, b) = lcm(a, b) 所以c/a = b/gcd(a, b) 而我们要求的是b,所以可以枚举b/gcd(a, b)的倍数直到c 这个过程中第一个满足条件的数就是b 代码如下: #include <cstdio>#include <iostream>#include <al

UVa 11889 Benefit (数论)

UVa 11889 Benefit 题目大意: 给两个整数A和C,求最小的整数B使得lcm(A,B)=C.若无解,输出”NO SOLUTION”(不含引号). 题目分析: 显然可知,若C%A!=0,则无解. 对于有解的情况,如下 设 A=g∗p1B=g∗p2C=g∗p1∗p2 A=g*p_1\\B=g*p_2\\C=g*p_1*p_2 要使 lcm(A,B)=C lcm(A

uva 11889 Benefit

原题: Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, he who never has appropriate changes, asks for B Tomans such that lowest common multiple of A and B eq