解题思路:
求出每个数的所有质因数,对于每个数分别用Counter类记录每个质因数的个数,最后将三个Counter取并集,求得最小公倍数
注意事项:
Counter的具体用法可以参考https://zhuanlan.zhihu.com/p/355601478
参考代码:
from collections import Counter a,b,c = map(int,input().split()) def get(x): res = Counter() t = 2 while t<=x: if x%t==0: res[t] += 1 x //= t else: t += 1 return res A = get(a) B = get(b) C = get(c) D = A | B | C res = 1 for key in D.keys(): res *= pow(key,D[key]) print(res)
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题6.6 (C++代码)浏览:633 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:472 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:609 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:543 |
IP判断 (C语言代码)浏览:539 |
图形输出 (C语言代码)浏览:944 |
字符逆序 (C语言代码)浏览:509 |
神奇的fans (C语言代码)浏览:986 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:610 |
C二级辅导-分段函数 (C语言代码)浏览:755 |