結果
| 問題 | No.368 LCM of K-products | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-10 21:00:48 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 292 ms / 2,000 ms | 
| コード長 | 945 bytes | 
| コンパイル時間 | 1,591 ms | 
| コンパイル使用メモリ | 182,276 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 18:09:42 | 
| 合計ジャッジ時間 | 3,121 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
long long my_power(ll a,ll b){
	long long res=1;
	a%=mod;
	while(b){
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return (res);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,y;
  cin>>n>>y;
  vector<ll>v(n);
  for(ll i=0;i<n;i++){
	  cin>>v[i];
  }
  map<ll,vector<ll>>m;
  for(ll i=0;i<ll(v.size());i++){
	  ll x=v[i];
	  for(ll j=2;j*j<=x;j++){
		  if(x%j==0){
			  ll cnt=0;
			  while(x%j==0){
				  cnt++;
				  x=x/j;
			  }
			  m[j].push_back(cnt);
		  }
	  }
	  if(x>1)m[x].push_back(1);
  }
  long long ans=1;
  for(auto k:m){
	  vector<ll>a=k.second;
	  sort(a.rbegin(),a.rend());
	  ll x=0;
	  for(ll i=0;i<min(ll(a.size()),y);i++){
		  x+=a[i];
	  }
	  ans*=(my_power(k.first,x));
	  ans%=mod;
  }
  cout<<ans<<endl;
 }
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
  
            
            
            
        