hdu 2028
2015-08-01 15:01
176 查看
#include <iostream> #include <cstdio> using namespace std; int a[10010]; int gcd(int a, int b){ // 求a, b最大公约数; return (b == 0 ? a : gcd(b, a%b)); } int main() { int n; while(scanf("%d", &n) != EOF){ for(int i = 0; i < n; ++i){ scanf("%d", &a[i]); } int t = a[0]; for(int i = 1; i < n; ++i){ int r = gcd(t, a[i]); t = (t / r * a[i]); //依次求出最小公倍数; } cout << t << endl; } return 0; }
相关文章推荐
- oj上常见错误提示
- STM32 HAL库头文件包含关系
- POJ 2528 Mayor's posters
- Xcode 插件失效的临时解决方案
- Windows 10正式版字体乱码显示为方块怎么办?
- hdoj.5112 A Curious Matt【sort+暴力】 2015/08/01
- C#(WinForm) ComboBox和ListBox添加项
- 暑期训练--阶段总结
- [python]如何快速地翻转字符串
- clk prepare和enable的问题
- ioctl()在LINUX设备驱动中的用法(转)
- Codeforces 556A Case of the Zeros and Ones(消除01)
- 计算有比多少矩形
- 循环冗余校验(CRC)算法入门引导
- setsockopt()用法(参数详细说明)
- Spring+Struts2+Mybatis框架搭建时的常见典型问题
- 机试算法讲解: 第52题 动态规划之搬寝室问题
- windows的socket_tcp服务端与 windows的socket_tcp客服端简单通讯
- C - Courses - hdu 1083(模板)
- 用CSS做圆角矩形