結果
問題 |
No.368 LCM of K-products
|
ユーザー |
![]() |
提出日時 | 2016-06-18 07:06:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 1,928 ms |
コンパイル使用メモリ | 180,560 KB |
実行使用メモリ | 16,976 KB |
最終ジャッジ日時 | 2024-10-09 20:27:08 |
合計ジャッジ時間 | 8,476 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int mod=1e9+7; int main(){ int n,k; cin>>n>>k; map<int,vector<int>> mp; for(int i=0;i<n;i++){ int a; cin>>a; for(int j=2;a>1;j++){ int add=0; while(a%j==0){ add++; a/=j; } if(add) mp[j].push_back(add); } } long long ans=1; for(auto i:mp){ auto vec=i.second; sort(vec.begin(),vec.end()); reverse(vec.begin(),vec.end()); int p=0; for(int j=0;j<k&&j<vec.size();j++){ p+=vec[j]; } long long multi=i.first; while(p){ if(p&1) (ans*=multi)%=mod; (multi*=multi)%=mod; p/=2; } } cout<<ans<<endl; return 0; }