結果

問題 No.368 LCM of K-products
ユーザー btkbtk
提出日時 2016-04-29 23:17:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 908 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 180,372 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 21:10:19
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,348 KB
testcase_01 AC 29 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 10 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 97 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 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 8 ms
4,348 KB
testcase_14 AC 11 ms
4,348 KB
testcase_15 AC 13 ms
4,348 KB
testcase_16 AC 10 ms
4,348 KB
testcase_17 AC 10 ms
4,348 KB
testcase_18 AC 12 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 12 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 5 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
* Problem link
* 
*/

#include<bits/stdc++.h>
using namespace std;

struct INIT{INIT(){cin.tie(0);ios_base::sync_with_stdio(false);} }init;

typedef long long LL;
const LL MOD = (LL)1e9 + 7;
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	map<int, vector<int>> m;
	int N,K;
	cin >> N >> K;
	vector<int> v(N);
	for (auto& it : v)cin >> it;
	for (auto& it : v) {
		for (int i = 2; i*i <= it; i++) {
			if (it%i == 0) {
				int cnt = 0;
				while (it%i == 0) { cnt++, it /= i; }
				//cout << i << " " << cnt << endl;
				m[i].push_back(cnt);
			}
		}
		if (it != 1)m[it].push_back(1);
	}
	LL res = 1;
	for (auto& u : m) {
		auto& p = u.second;
		sort(p.begin(),p.end());
		reverse(p.begin(), p.end());
		for (int i = 0; i < min((int)p.size(),K); i++)
			for (int j = 0; j < p[i]; j++)
				(res *= u.first) %= MOD;
	}

	cout << res << endl;
	return 0;
}
0