結果

問題 No.368 LCM of K-products
ユーザー rickythetarickytheta
提出日時 2016-04-29 23:02:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 1,755 ms
コンパイル使用メモリ 168,144 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 21:09:10
合計ジャッジ時間 3,043 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,348 KB
testcase_01 AC 62 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 18 ms
4,348 KB
testcase_04 AC 14 ms
4,348 KB
testcase_05 AC 134 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 13 ms
4,348 KB
testcase_14 AC 23 ms
4,348 KB
testcase_15 AC 27 ms
4,348 KB
testcase_16 AC 21 ms
4,348 KB
testcase_17 AC 19 ms
4,348 KB
testcase_18 AC 28 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 17 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 26 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 8 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |           ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#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;
}
0