hdu 2028 Lowest Common Multiple Plus
来源:互联网 发布:cgwang插画网络 编辑:程序博客网 时间:2024/05/01 01:04
题意是求n个数的最大公约数,挺简单的,水题一枚,可是wa了若干次,只因return m/gcd(m,n)*n;
写成return m*n/gcd(m,n);
至今不知为啥,请路过之人指教一二,不甚感谢!
#include <iostream>#include<cstdio>#include<cstring>using namespace std;int gcd(int m,int n){ if(n==0) return m; else return gcd(n,m%n);}int lcm(int m,int n) { return m/gcd(m,n)*n; }int main(){ int n,i; int s,t; while(cin>>n) { s=1; while(n--) { cin>>t; s=lcm(s,t); } cout<<s<<endl; } return 0;}
- HDU 2028 Lowest Common Multiple Plus
- hdu - 2028 - Lowest Common Multiple Plus
- hdu 2028 Lowest Common Multiple Plus
- HDU 2028 - Lowest Common Multiple Plus (最小公倍数)
- [hdu 2028] Lowest Common Multiple Plus
- HDU 2028 Lowest Common Multiple Plus
- HDU 2028 Lowest Common Multiple Plus
- hdu 2028 Lowest Common Multiple Plus
- HDU 2028 Lowest Common Multiple Plus
- hdu 2028 Lowest Common Multiple Plus
- HDU - 2028 Lowest Common Multiple Plus
- hdu 2028 Lowest Common Multiple Plus
- HDU 2028 Lowest Common Multiple Plus
- hdu 2028 Lowest Common Multiple Plus
- HDU 2028 Lowest Common Multiple Plus
- HDU--2028-Lowest Common Multiple Plus
- HDU-2028 Lowest Common Multiple Plus
- HDU-2028 Lowest Common Multiple Plus
- ORACLE 定时任务 JOB_QUEUE_PROCESSES 的设置
- 网络编程基础
- 创建文件并进行读写
- 如何搭建Flash P2P网络直播点播平台
- JAVA的StringBuffer类
- hdu 2028 Lowest Common Multiple Plus
- 按钮位置编辑
- 非对称双核MCU基础知识及核间通信
- 色彩提取及应用技巧
- Redis服务器配置
- HDU 3123 大数阶乘取模
- IOS5 ARC unsafe_unretained等说明
- 包和命名空间
- 排序之直接插入排序