您的位置:首页
HDU 1019 Least Common Multiple 数学题解
2018-04-20 15:52
447 查看
求一组数据的最小公倍数。
先求公约数在求公倍数。利用公倍数,连续求全部数的公倍数就能够了。
先求公约数在求公倍数。利用公倍数,连续求全部数的公倍数就能够了。
#include <stdio.h> int GCD(int a, int b) { return b? GCD(b, a%b) : a; } inline int LCM(int a, int b) { return a / GCD(a, b) * b; } int main() { int T, m, a, b; scanf("%d", &T); while (T--) { scanf("%d %d", &m, &a); while (--m) { scanf("%d", &b); a = LCM(a, b); } printf("%d\n", a); } return 0; }
相关文章推荐
- hdu 1019 Least Common Multiple 简单数学
- HDU 1019 Least Common Multiple 数学题解
- HDU 1019 Least Common Multiple 数学题
- hdu 1019 Least Common Multiple(最小公倍数)
- hdu 1019 Least Common Multiple
- HDU 1019:Least Common Multiple
- hdu 1019 Least Common Multiple (水题,LCM)
- HDU 1019 Least Common Multiple
- HDU 1019 Least Common Multiple (最小公倍数)
- HDU 1019 Least Common Multiple
- HDU-1019-Least Common Multiple( 最大公约数 && 最小公倍数 && GCD )
- hdu1019 Least Common Multiple
- HDU 1019 Least Common Multiple
- hdu 1019 Least Common Multiple(LCM的运用)
- hdu 1019 Least Common Multiple_水题
- HDU 1019 Least Common Multiple
- HDOJ 1019 Least Common Multiple(数学)
- 杭电 HDU 1019 Least Common Multiple
- hdu 1019 Least Common Multiple
- Least Common Multiple HDU 1019