結果

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

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long my_power(int a,int 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);
  int n,y;
  cin>>n>>y;
  vector<int>v(n);
  for(int i=0;i<n;i++){
	  cin>>v[i];
  }
  map<int,vector<int>>m;
  for(int i=0;i<int(v.size());i++){
	  int x=v[i];
	  for(int j=2;j*j<=x;j++){
		  if(x%j==0){
			  int 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<int>a=k.second;
	  sort(a.rbegin(),a.rend());
	  int x=0;
	  for(int i=0;i<min(int(a.size()),y);i++){
		  x+=a[i];
	  }
	  ans*=(my_power(k.first,x));
	  ans%=mod;
  }
  cout<<ans<<endl;
 }
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
  
0