結果

問題 No.1463 Hungry Kanten
ユーザー tabae326
提出日時 2021-04-02 21:57:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 746 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 198,264 KB
最終ジャッジ日時 2025-01-20 09:10:03
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

const ll mod = 998244353;
void add(ll &a, ll b) { (a += b); }
void mul(ll &a, ll b) { (a *= b); }

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    set<ll> st;
    rep(bit, 0, (1<<n)) {
        if(__builtin_popcount(bit) < k) continue;
        ll x = 0, y = 1;
        rep(i, 0, n) if(bit & (1<<i)) add(x, a[i]);
        rep(i, 0, n) if(bit & (1<<i)) mul(y, a[i]);
        st.insert(x);
        st.insert(y);
    }
    cout << st.size() << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
0