結果
| 問題 |
No.368 LCM of K-products
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2018-09-28 11:54:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 1,185 bytes |
| コンパイル時間 | 858 ms |
| コンパイル使用メモリ | 101,636 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 14:56:20 |
| 合計ジャッジ時間 | 2,285 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#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;
}
chocorusk