結果

問題 No.368 LCM of K-products
ユーザー h_noson
提出日時 2016-04-30 00:09:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 60,024 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 19:50:15
合計ジャッジ時間 1,251 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
#define MOD 1000000007

typedef long long ll;

ll gcd(int a, int b) {
    return b == 0 ? a : gcd(b,a%b);
}

ll power(ll x, int n) {
    ll ret = 1;
    while (n > 0) {
        if (n % 2) {
            ret *= x;
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n /= 2;
    }
    return ret;
}

int main() {
    int i, n, k, d;
    ll ans;
    int a[1000];
    cin >> n >> k;
    rep (i,n) cin >> a[i];
    ans = 1;
    rep (i,n) ans = (ans * a[i]) % MOD;
    d = a[0];
    REP (i,1,n) d = gcd(d,a[i]);
    ans = (ans * power(d,MOD-2)) % MOD;
    cout << ans << endl;
    return 0;
}
0