結果

問題 No.368 LCM of K-products
ユーザー ctyl_0ctyl_0
提出日時 2016-04-29 23:50:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 06:11:40
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 24 ms
6,940 KB
testcase_04 AC 22 ms
6,940 KB
testcase_05 AC 16 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 55 ms
6,944 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 WA -
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1 ms
6,944 KB
testcase_33 WA -
testcase_34 AC 43 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b) * b) % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    
    ll ret = 1;
    rep(i, K) {
        ret *= A[i];
        ret %= mod;
    }
    
//    cout << ret << endl;
    
    repd(i, K, N) {
        ll l = 1;
        rep(j, i) {
            ll g = gcd(A[i], A[j]);
//            cout << "g: " << g << endl;
            l = lcm(l, A[i] / g);
//            cout << "l: " << l << endl;
        }
        (ret *= l) %= mod;
//        cout << ret << endl;
    }
    
    output(ret, 0);
    
    return 0;
}
0