codevs1459n个数的最小公倍数
来源:互联网 发布:东京食尸鬼面具淘宝 编辑:程序博客网 时间:2024/06/16 05:03
自己动手算一下就会发现规律
#include <cstdio>#include <cstring>#include <iostream>#include <cmath>#include <algorithm>using namespace std;int h[233];int lcm(int a,int b){ int y; int x = a; int z = b; while(a%b != 0) { y = a%b; a = b; b = y; } int aa = x/b; int bb = z/b; int ans; ans = aa*bb*b; return ans;}int main(){ int n; scanf("%d",&n); for(int i = 1; i <= n; i ++) scanf("%d",&h[i]); sort(h+n,h+n+1); int ans ; for(int i = 2; i <= n; i ++) { ans = lcm(h[i-1],h[i]); h[i] = ans; } printf("%d",ans); return 0;}
1 0
- codevs1459n个数的最小公倍数
- n个数的最小公倍数
- 多个数的最小公倍数
- n个数的最小公倍数
- 多个数的最小公倍数
- n个数的最小公倍数
- 多个数的最小公倍数
- 多个数的最小公倍数
- n个数的最小公倍数
- HDOJ1019多个数的最小公倍数
- 求多个数的最小公倍数
- 求任意个数的最小公倍数
- 求N个数的最小公倍数
- 求多个数的最小公倍数
- 求N个数的最小公倍数
- 求N个数的最小公倍数
- 求多个数的最小公倍数
- 多个数的最小公倍数求法
- JAVA刷网站流量的技术研究总结
- PHP5.5以上V9会一直报错, mysql 如何改为 mysqli
- poj2386(BFS与DFS)
- openjudge约瑟夫问题
- TCP BBR算法与Reno/CUBIC的对比
- codevs1459n个数的最小公倍数
- 搞懂树状数组
- OpenJudge noi 1804小游戏(POJ1101)
- OpenJudge noi253 丛林中的路
- LICS
- 【模板】最短路&&最小生成树
- [NOIP2015][Vijos1977]推销员(heap)
- 洛谷 P2278 操作系统
- 【poj】 3321 Apple Tree dfs序+树状数组