結果

問題 No.368 LCM of K-products
ユーザー fiord
提出日時 2016-06-19 01:14:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 594 bytes
コンパイル時間 1,526 ms
コンパイル使用メモリ 170,324 KB
実行使用メモリ 16,712 KB
最終ジャッジ日時 2024-10-10 02:44:52
合計ジャッジ時間 8,096 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){
	int n,k;	cin>>n>>k;
	
	map<int,multiset<int>> mp;
	for(int i=0;i<n;i++){
		int a;	cin>>a;
		for(int j=2;a>1;j++){
			int add=0;
			while(a%j==0){
				add++;
				a/=j;
			}
			if(add)	mp[j].insert(add);
		}
	}
	long long ans=1;
	for(auto i:mp){
		auto it=i.second;
		int cnt=0;
		int p=0;
		for(auto j=it.rbegin();j!=it.rend();j++){
			p+=*j;	cnt++;
			if(cnt==k)	break;
		}
		long long multi=i.first;
		while(p){
			if(p&1)	(ans*=multi)%=mod;
			(multi*=multi)%=mod;
			p/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0