結果

問題 No.1463 Hungry Kanten
ユーザー yansi819
提出日時 2024-04-29 11:23:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 7,713 ms
コンパイル使用メモリ 416,540 KB
実行使用メモリ 24,960 KB
最終ジャッジ日時 2025-06-20 02:07:37
合計ジャッジ時間 9,266 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
namespace mul = boost::multiprecision;
using ll = long long;
using ld = long double;
using mint = modint998244353;

int main() {
  int N, M, K, ans = 0;
  mul::cpp_int x, y;
  cin >> N >> K;
  M = 1 << N;

  vector<int> A(N);
  set<mul::cpp_int> st;
  for (int i = 0; i < N; i++) cin >> A[i];

  for (int i = 0; i < M; i++) {
    if (__builtin_popcount(i) < K) continue;
    x = 0, y = 1;
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        x += A[j];
        y *= A[j];
      }
    }
    st.insert(x);
    st.insert(y);
  }
  cout << st.size() << endl;
  return 0;
}
0