結果

問題 No.368 LCM of K-products
ユーザー baLoon8128baLoon8128
提出日時 2022-04-23 16:36:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 4,256 ms
コンパイル使用メモリ 235,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 09:30:19
合計ジャッジ時間 6,591 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 36 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 121 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 14 ms
4,376 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 12 ms
4,376 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 15 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 7 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:33:15: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   33 |     for (auto [p, cnt] : mp) {
      |               ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

using mint = modint1000000007;
int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, vi> mp;
    for (int x : a) {
        for (int k = 2; k * k <= x; k++) {
            if (x % k == 0) {
                int c = 0;
                while (x % k == 0) {
                    x /= k;
                    c++;
                }
                mp[k].push_back(c);
            }
        }
        if (x > 0) mp[x].push_back(1);
    }
    mint r = 1;
    for (auto [p, cnt] : mp) {
        sort(cnt.begin(), cnt.end(), greater<int>());
        int m = 0;
        rep(i, min(k, (int)cnt.size())) m += cnt[i];
        r *= mint(p).pow(m);
    }
    cout << r.val() << endl;
    return 0;
}
0