結果

問題 No.1463 Hungry Kanten
ユーザー Example0911Example0911
提出日時 2021-04-03 10:32:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,097 bytes
コンパイル時間 3,022 ms
コンパイル使用メモリ 219,936 KB
実行使用メモリ 252,076 KB
最終ジャッジ日時 2023-08-26 00:59:18
合計ジャッジ時間 8,773 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 47 ms
9,120 KB
testcase_03 AC 175 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 TLE -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 15 ms
5,572 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 57 ms
12,084 KB
testcase_17 AC 170 ms
20,572 KB
testcase_18 AC 43 ms
10,208 KB
testcase_19 AC 972 ms
99,584 KB
testcase_20 AC 1,180 ms
132,580 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, K; cin >> N >> K;
	vector<ll>A(N); for (int i = 0; i < N; i++)cin >> A[i];
	vector<map<ll, ll>>t(N);for(int i = 0; i < N; i++) t[i] = prime_factor(A[i]);
	map<map<ll, ll>, bool>mp;
	for (ll bit = 0; bit < (1LL << N); bit++) {
		int cnt = 0;
		for (ll i = 0; i < N; i++) {
			if (bit >> i & 1) {
				cnt++;
			}
		}
		if (cnt < K)continue;
		ll sum = 0;
		for (int i = 0; i < N; i++) {
			if (bit >> i & 1) {
				sum += A[i];
			}
		}
		auto p = prime_factor(sum);
		mp[p] = true;
		map<ll, ll>tmp;
		for (int i = 0; i < N; i++) {
			if (bit >> i & 1) {
				for (auto y : t[i]) {
					tmp[y.first] += y.second;
				}
			}
		}
		mp[tmp] = true;
	}
	cout << mp.size() << endl;
	return 0;
}
0