zoukankan      html  css  js  c++  java
  • Lowest Common Multiple Plus

    Problem Description
    求n个数的最小公倍数。
     
    Input
    输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数。
     
    Output
    为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行。你可以假设最后的输出是一个32位的整数。
     
    Sample Input
    2 4 6 3 2 5 7
     
    Sample Output
    12
    70
              一直被卡,原来是说输出32位整数。应该是超出了int的范围、
     1 #include<iostream>
     2 #include<iomanip>
     3 //#include<bits/stdc++.h>
     4 #include<cstdio>
     5 #include<cmath>
     6 #include<sstream>
     7 #define PI  3.14159265358979
     8 #define LL long long
     9 #define  eps   0.00000001
    10 #define LL long long
    11 using namespace std;
    12 LL gcd(LL a,LL b)
    13 {
    14     if(a<b) swap(a,b);
    15     LL r=a%b;
    16     while(r)
    17     {
    18         a=b;
    19         b=r;
    20         r=a%b;
    21     }
    22     return b;
    23 }
    24 int main()
    25 {
    26    // freopen("input.txt","r",stdin);
    27     LL T;
    28     while(cin>>T)
    29     {
    30         LL a;
    31         cin>>a;
    32         LL temp=a;
    33         for(LL i=2;i<=T;++i)
    34         {
    35             cin>>a;
    36              temp=temp*a/gcd(temp,a);
    37         }
    38         cout<<temp<<endl;
    39 
    40     }
    41 }
    View Code
  • 相关阅读:
    ArcgisServerJS固件位置
    PrintTemplate说明
    地图打印仅地图4X
    地图打印4X
    IIS下设置跨域访问问题--Access-Control-Allow-Origin 站点跨域请求的问题
    javascript的 热点图怎么写
    Flex 加载shp
    Flex 加载dwg
    Flex 加载tiff
    Flex 加载 wmf,svg
  • 原文地址:https://www.cnblogs.com/Auroras/p/10800688.html
Copyright © 2011-2022 走看看