結果

問題 No.368 LCM of K-products
ユーザー Mr.SpockMr.Spock
提出日時 2020-11-10 21:00:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 945 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 180,084 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 00:11:36
合計ジャッジ時間 3,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
 }
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
  
0