結果
問題 | No.368 LCM of K-products |
ユーザー |
|
提出日時 | 2020-11-10 20:55:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 940 bytes |
コンパイル時間 | 1,605 ms |
コンパイル使用メモリ | 181,700 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 18:09:34 |
合計ジャッジ時間 | 2,893 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 15 |
ソースコード
#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; }