結果

問題 No.1463 Hungry Kanten
ユーザー umezoumezo
提出日時 2021-04-02 21:31:24
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 528 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 206,796 KB
実行使用メモリ 15,668 KB
最終ジャッジ日時 2023-08-25 14:47:50
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 121 ms
15,668 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 12 ms
4,744 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 55 ms
9,660 KB
testcase_20 AC 74 ms
11,176 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  set<ll> s;
  
  for(int bit=0;bit<(1<<n);bit++){
    if(__builtin_popcount(bit)<k) continue;
    ll sum=0;
    ll mul=1;
    for(int i=0;i<n;i++){
      if(bit&(1<<i)){
        sum+=A[i];
        mul*=A[i];
      }
    }
    s.insert(sum);
    s.insert(mul);
  }
  cout<<s.size()<<endl;

  return 0;
}
0