hdu 1019 Least Common Multiple
来源:互联网 发布:数组大小可以任意改变 编辑:程序博客网 时间:2024/05/01 05:49
#include<stdio.h>int gcd(int a, int b){ if (a < b) { int x = a; a = b; b = x; } if (a%b == 0) return b; return gcd(b, a%b);}int main(){ int T, a, b, n; scanf("%d", &T); while (T--) { scanf("%d", &n); scanf("%d", &a); for (; n > 1; n--) { scanf("%d", &b); a = a/gcd(a, b) *b; //注意这里写成 a*b/gcd(a, b) 就会WA } printf("%d\n", a); }}
0 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
- hdu 1019Least Common Multiple
- hdu 1019 Least Common Multiple
- hdu 1019 Least Common Multiple
- Hdu 1019 Least Common Multiple
- hdu 1019 Least Common Multiple
- HDU 1019Least 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
- POJ 1009 Edge Detection
- 中级JavaScript例子, 如何实现一个简单实用的模板套用机制, GXTemplate , 第2章(估计要写9章)
- 1043. 输出PATest(20)
- 算法的简单介绍
- C# 类的继承
- hdu 1019 Least Common Multiple
- hdu2296||UVALive 4223 Trucking (二分+spfa)
- LeetCode Algorithms #235 <Lowest Common Ancestor of a Binary Search Tree>
- Android中SQLite应用详解
- Android-AnimViewPager自定义切换效果
- Android OkHttp完全解析 是时候来了解OkHttp了
- Hadoop:The Definitive Guide 4th Edition
- 《老罗Android》学习之SQLite
- MongoDB_条件操作符