結果
| 問題 |
No.368 LCM of K-products
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-04-29 23:02:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 1,276 bytes |
| コンパイル時間 | 1,412 ms |
| コンパイル使用メモリ | 168,380 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 14:42:08 |
| 合計ジャッジ時間 | 2,885 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:39:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | REP(i,n)scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
int n,k;
int a[1252];
vi ps[1252];
int st[1252];
ll mdpw(ll a,ll b){
ll r = 1;
while(b){
if(b&1)r=r*a%MOD;
a=a*a%MOD;
b>>=1;
}
return r;
}
int main(){
scanf("%d%d",&n,&k);
REP(i,n)scanf("%d",&a[i]);
set<int> P;
REP(i,n){
int x = a[i];
for(int j=2;j*j<=x;++j){
if(x%j!=0)continue;
P.insert(j);
while(x%j==0)x/=j; //, ps[i].push_back(j);
}
if(x>1)P.insert(x);
}
ll ans = 1;
for(int p:P){
REP(i,n){
int x = a[i];
st[i] = 0;
while(x%p==0)x/=p,st[i]++;
}
sort(st,st+n);
reverse(st,st+n);
int cnt = 0;
REP(i,k)cnt += st[i];
// DEBUG(p);
// DEBUG(cnt);
ans = ans * mdpw(p,cnt) % MOD;
}
printf("%lld\n",ans);
return 0;
}
rickytheta