結果

問題 No.1463 Hungry Kanten
ユーザー polyesterpolyester
提出日時 2021-04-02 22:06:45
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 15,377 ms
コンパイル使用メモリ 222,376 KB
実行使用メモリ 33,272 KB
最終ジャッジ日時 2023-08-25 14:59:50
合計ジャッジ時間 17,089 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 10 ms
4,592 KB
testcase_03 AC 89 ms
4,356 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 293 ms
33,272 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 12 ms
4,924 KB
testcase_17 AC 31 ms
6,728 KB
testcase_18 AC 21 ms
4,508 KB
testcase_19 AC 170 ms
18,124 KB
testcase_20 AC 248 ms
20,956 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  vector<Bint> a(n);
  map<Bint, Bint> mp;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int bit = 0; bit < (1 << n); bit++) {
    int cnt = 0;
    Bint s = 0, m = 1;
    for(int i = 0; i < n; i++) {
      if(bit & (1 << i)) {
        cnt++;
        s += a[i];
        m *= a[i];
      }
    }
    if(cnt >= k) {
      mp[s]++;
      mp[m]++;
    }
  }
  cout << mp.size() << endl;

  return 0;
}
0