HDU Least Common Multiple
来源:互联网 发布:异性缘好的男生 知乎 编辑:程序博客网 时间:2024/05/19 10:10
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1019
本题应该是唯一的一道一次AC的题目了,使用的数论结论可以参考数论的结论,GCD和LCM以及拓展定理。
#include<stdio.h>#include<string.h>//#define LOCALusing namespace std;int gcd(int a,int b){ //b看做除数 return a%b==0?b:gcd(b,a%b);}int lcm(int a,int b){ return a/gcd(a,b)*b; //防止溢出}int main(){ #ifdef LOCAL freopen("input.txt","r",stdin); #endif // LOCAL int T=0; scanf("%d",&T); while(T--){ int N=0; int result=0; int pre=1,next=0; scanf("%d",&N); for(int i=0;i<N;i++){ scanf("%d",&next); pre=lcm(pre,next); } result=pre; printf("%d\n",result); } return 0;}
0 0
- hdu Least Common Multiple
- HDU 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 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
- 关于struts2框架学习
- Spring分布式事务实现
- C#的ArrayList类
- 设计模式(二)
- Mac下配置Nginx服务器
- HDU Least Common Multiple
- Unity3D 5 官方教程:标准着色器:内容和环境;金属与镜面工作流
- TortoiseSVN 图文使用教程
- UVA10020用最少的线段去覆盖给定的线段
- leetcode:Integer to Roman 【Java】
- Android系统之SD卡分析二
- head first 设计模式学习之策略模式
- javascript正则函数
- python中单元测试doctest | unittest