結果

問題 No.368 LCM of K-products
ユーザー sugim48sugim48
提出日時 2016-04-29 22:45:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,487 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 88,720 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-23 21:08:45
合計ジャッジ時間 2,541 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
4,368 KB
testcase_01 AC 54 ms
4,368 KB
testcase_02 AC 3 ms
4,368 KB
testcase_03 AC 17 ms
4,368 KB
testcase_04 AC 11 ms
4,368 KB
testcase_05 AC 131 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,368 KB
testcase_13 AC 12 ms
4,368 KB
testcase_14 AC 21 ms
4,368 KB
testcase_15 AC 24 ms
4,368 KB
testcase_16 AC 19 ms
4,368 KB
testcase_17 AC 16 ms
4,368 KB
testcase_18 AC 24 ms
4,368 KB
testcase_19 AC 5 ms
4,368 KB
testcase_20 AC 15 ms
4,368 KB
testcase_21 AC 4 ms
4,368 KB
testcase_22 AC 23 ms
4,368 KB
testcase_23 AC 1 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,368 KB
testcase_26 AC 1 ms
4,368 KB
testcase_27 AC 1 ms
4,368 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 1 ms
4,368 KB
testcase_30 AC 1 ms
4,368 KB
testcase_31 AC 1 ms
4,368 KB
testcase_32 AC 1 ms
4,368 KB
testcase_33 AC 8 ms
4,368 KB
testcase_34 AC 3 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int pow_mod(ll x, ll n, int M) {
	ll ans = 1;
	for (; n; n>>=1) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
	}
	return ans;
}

int main() {
	int N, K; cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];
	vector<int> ps;
	for (int x: a) {
		for (int p = 2; p * p <= x; p++)
			if (x % p == 0) {
				ps.push_back(p);
				for (; x % p == 0; x /= p);
			}
		if (x > 1) ps.push_back(x);
	}
	sort(ps.begin(), ps.end());
	ps.erase(unique(ps.begin(), ps.end()), ps.end());
	int ans = 1;
	for (int p: ps) {
		vector<int> b(N);
		for (int i = 0; i < N; i++)
			for (int x = a[i]; x % p == 0; x /= p)
				b[i]++;
		sort(b.begin(), b.end());
		reverse(b.begin(), b.end());
		int sum = 0;
		for (int i = 0; i < K; i++)
			sum += b[i];
		ans = (ll)ans * pow_mod(p, sum, MOD) % MOD;
	}
	cout << ans << endl;
}
0