結果

問題 No.1463 Hungry Kanten
ユーザー Example0911Example0911
提出日時 2021-04-02 21:33:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,048 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 217,628 KB
実行使用メモリ 256,340 KB
最終ジャッジ日時 2023-08-25 14:49:33
合計ジャッジ時間 6,681 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 58 ms
9,284 KB
testcase_03 AC 661 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 TLE -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 17 ms
5,624 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 63 ms
12,256 KB
testcase_17 AC 185 ms
20,732 KB
testcase_18 AC 55 ms
10,312 KB
testcase_19 AC 972 ms
99,868 KB
testcase_20 AC 1,215 ms
132,796 KB
testcase_21 AC 2 ms
4,500 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];
	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) {
				auto x = prime_factor(A[i]);
				for (auto y : x) {
					tmp[y.first] += y.second;
				}
			}
		}
		mp[tmp] = true;
	}
	cout << mp.size() << endl;
	return 0;
}
0