結果

問題 No.1463 Hungry Kanten
ユーザー bonKotsubonKotsu
提出日時 2021-04-19 23:54:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 821 bytes
コンパイル時間 1,893 ms
コンパイル使用メモリ 179,756 KB
実行使用メモリ 196,060 KB
最終ジャッジ日時 2023-09-17 08:33:51
合計ジャッジ時間 8,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 51 ms
7,936 KB
testcase_03 AC 327 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 TLE -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 14 ms
5,056 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 56 ms
10,260 KB
testcase_17 AC 148 ms
17,116 KB
testcase_18 AC 103 ms
8,700 KB
testcase_19 AC 825 ms
78,664 KB
testcase_20 AC 1,132 ms
104,256 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];


  auto factorize = [&](map<int, int>& mp, int x) {
    for (int i = 2; i*i <= x; i++) {
      if (x%i==0) {
        while(x%i==0) {
          mp[i]++;
          x /= i;
        }
      }
    }
    if (x > 1) mp[x]++;
  };

  set<map<int,int>> s;
  rep(bit, 1<<n) {
    int cnt = 0;
    int sum = 0;
    map<int, int> mp_sum, mp_prod;
    rep(j, n) {
      if (bit>>j&1) {
        cnt++;
        sum += a[j];
        factorize(mp_prod, a[j]);
      }
    }
    if (cnt < k) continue;
    factorize(mp_sum, sum);
    s.insert(mp_sum);
    s.insert(mp_prod);
  }
  cout << s.size() << endl;

}
0