#1192: 還有更快的算法嗎??


B88000005 (喔~~!!XD)


這題因為是很多個數字的最小公倍數,

所以好像不能使用輾轉相除法??

所以我用了先把前面乘起來之後跟下一個數字的關係,

以下是我的式子:

#include <iostream>
#include <string>
#include <sstream>

using namespace std;
int c=0,q=0;
int GCD(int o,int p){
    while(p>0){
        c=o%p;
        o=p;
        p=c;
    }
    q=o;
}
int main()
{
    string x;
    stringstream X;
    while(getline(cin,x)){
        X.clear();
        X.str(x);
        int n=0;
        long long m=1;
        while(X>>n){
            if(n==0){
                return 0;
            }
            GCD(m,n);
            if(q==1){
                m*=n;
            }
            else{
                m=m*n/q;
            }
        }
        cout<<m<<endl;
    }
    return 0;
}

可是還是會超過1S耶??

最快的好像超過兩百微秒??

這題的時間可不可以再長一點ˊˋ?
#1199: Re:還有更快的算法嗎??


magrady (元元)


這題因為是很多個數字的最小公倍數,

所以好像不能使用輾轉相除法??

所以我用了先把前面乘起來之後跟下一個數字的關係,

以下是我的式子:

#include
#include
#include

using namespace std;
int c=0,q=0;
int GCD(int o,int p){
    while(p>0){
        c=o%p;
        o=p;
        p=c;
    }
    q=o;
}
int main()
{
    string x;
    stringstream X;
    while(getline(cin,x)){
        X.clear();
        X.str(x);
        int n=0;
        long long m=1;
        while(X>>n){
            if(n==0){
                return 0;
            }
            GCD(m,n);
            if(q==1){
                m*=n;
            }
            else{
                m=m*n/q;
            }
        }
        cout<<
    }
    return 0;
}

可是還是會超過1S耶??

最快的好像超過兩百微秒??

這題的時間可不可以再長一點ˊˋ?

這題主要是在考快速輸出入的技巧.

稍微看了一下,演算法應該是能AC的. 

#1200: Re:還有更快的算法嗎??


magrady (元元)


這題因為是很多個數字的最小公倍數,

所以好像不能使用輾轉相除法??

所以我用了先把前面乘起來之後跟下一個數字的關係,

以下是我的式子:

#include
#include
#include

using namespace std;
int c=0,q=0;
int GCD(int o,int p){
    while(p>0){
        c=o%p;
        o=p;
        p=c;
    }
    q=o;
}
int main()
{
    string x;
    stringstream X;
    while(getline(cin,x)){
        X.clear();
        X.str(x);
        int n=0;
        long long m=1;
        while(X>>n){
            if(n==0){
                return 0;
            }
            GCD(m,n);
            if(q==1){
                m*=n;
            }
            else{
                m=m*n/q;
            }
        }
        cout<<
    }
    return 0;
}

可是還是會超過1S耶??

最快的好像超過兩百微秒??

這題的時間可不可以再長一點ˊˋ?

這題主要是在考快速輸出入的技巧.

稍微看了一下,演算法應該是能AC的. 


我ReJudge後還是WA.
#1251: Re:還有更快的算法嗎??


gene91 (Gene JHZ)


這題因為是很多個數字的最小公倍數,

所以好像不能使用輾轉相除法??

所以我用了先把前面乘起來之後跟下一個數字的關係,

以下是我的式子:

#include
#include
#include

using namespace std;
int c=0,q=0;
int GCD(int o,int p){
    while(p>0){
        c=o%p;
        o=p;
        p=c;
    }
    q=o;
}
int main()
{
    string x;
    stringstream X;
    while(getline(cin,x)){
        X.clear();
        X.str(x);
        int n=0;
        long long m=1;
        while(X>>n){
            if(n==0){
                return 0;
            }
            GCD(m,n);
            if(q==1){
                m*=n;
            }
            else{
                m=m*n/q;
            }
        }
        cout<<
    }
    return 0;
}

可是還是會超過1S耶??

最快的好像超過兩百微秒??

這題的時間可不可以再長一點ˊˋ?

這題主要是在考快速輸出入的技巧.

稍微看了一下,演算法應該是能AC的. 


我ReJudge後還是WA.


题目中写道:

因為這個數可能很大 所以只要輸出%100000000的結果即可

答案并不一定在int范围内,同样不一定在long long范围内,所以你这样是会溢出的