結果
| 問題 |
No.368 LCM of K-products
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-05-18 22:23:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 695 bytes |
| コンパイル時間 | 1,645 ms |
| コンパイル使用メモリ | 176,924 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 14:47:30 |
| 合計ジャッジ時間 | 2,972 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
map<int,int> f(int n){
map<int,int> go;
for(int i = 2 ; i*i <= n ; i++){
int c = 0;
while( n % i == 0 ){
c++;
n /= i;
}
if(c) go[i] = c;
}
if( n != 1 ) go[n] += 1;
return go;
}
int main(){
int N,K;
cin >> N >> K;
map<int,vector<int>> S;
for(int i = 1 ; i <= N ; i++){
int a;
cin >> a;
for(auto i : f(a))
S[i.first].push_back(i.second);
}
long long ans = 1;
for( auto i : S ){
sort(i.second.rbegin(),i.second.rend());
if( i.second.size() > K ) i.second.resize(K);
int ss = 0;
for(auto j : i.second ) ss += j;
for(int j = 0 ; j < ss ; j++) ans *= i.first, ans %= (int)1e9+7;
}
cout << ans << endl;
}
kyuridenamida