結果

問題 No.368 LCM of K-products
ユーザー chocoruskchocorusk
提出日時 2018-09-28 11:54:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 99,820 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 21:26:33
合計ジャッジ時間 3,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
4,348 KB
testcase_01 AC 60 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 19 ms
4,348 KB
testcase_04 AC 18 ms
4,348 KB
testcase_05 AC 133 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 14 ms
4,348 KB
testcase_14 AC 26 ms
4,348 KB
testcase_15 AC 30 ms
4,348 KB
testcase_16 AC 24 ms
4,348 KB
testcase_17 AC 20 ms
4,348 KB
testcase_18 AC 32 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 18 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 29 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 9 ms
4,348 KB
testcase_34 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}

int main()
{
	int n, k;
	cin>>n>>k;
	map<int, int> pe[1000];
	set<int> pr;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		for(int j=2; j*j<=a; j++){
			if(a%j!=0) continue;
			pr.insert(j);
			int e=0;
			while(a%j==0){
				a/=j;
				e++;
			}
			pe[i][j]=e;
		}
		if(a>1){
			pr.insert(a);
			pe[i][a]=1;
		}
	}
	ll ans=1;
	for(auto p:pr){
		int e[1000];
		for(int i=0; i<n; i++){
			auto itr=pe[i].find(p);
			if(itr==pe[i].end()) e[i]=0;
			else e[i]=itr->second;
		}
		sort(e, e+n, greater<int>());
		int s=0;
		for(int i=0; i<k; i++){
			s+=e[i];
		}
		ans*=powmod((ll)p, (ll)s);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0