結果
| 問題 | No.1463 Hungry Kanten | 
| コンテスト | |
| ユーザー |  DaYuanChi | 
| 提出日時 | 2021-04-02 21:34:45 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 498 bytes | 
| コンパイル時間 | 1,647 ms | 
| コンパイル使用メモリ | 174,588 KB | 
| 実行使用メモリ | 15,616 KB | 
| 最終ジャッジ日時 | 2024-12-23 23:22:21 | 
| 合計ジャッジ時間 | 2,685 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, k; cin >> n >> k;
  vector<ll> a(n);
  set<ll> st;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int bit = 0; bit < (1<<n); bit++){
    ll sum = 0;
    ll pro = 1;
    if(__builtin_popcount (bit)<k) continue; 
    for(int j = 0; j < n; j++){
      if(bit&(1<<j)){
        sum += a[j];
        pro *= a[j];
      }
    }
    st.insert(sum);
    st.insert(pro);
  }
  cout << st.size() << endl;
  return 0;
}
            
            
            
        