結果

問題 No.1463 Hungry Kanten
ユーザー kaede2020kaede2020
提出日時 2021-04-03 08:20:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 3,869 ms
コンパイル使用メモリ 232,236 KB
実行使用メモリ 24,036 KB
最終ジャッジ日時 2023-08-25 22:45:38
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 9 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 228 ms
24,036 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,500 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 10 ms
4,604 KB
testcase_17 AC 25 ms
5,652 KB
testcase_18 AC 20 ms
4,380 KB
testcase_19 AC 135 ms
13,832 KB
testcase_20 AC 205 ms
15,880 KB
testcase_21 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
//using mint = modint1000000007;
using mint = modint998244353;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}


int main(){
  int n,k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  map<__int128,int>mp;
  rep(i,(1<<n)){
    int bit[20];
    rep(j,n){
      bit[j]=(i/(1<<j))%2;
    }
    __int128 tmp=0;
    __int128 tmp_kakeru=1;
    int cnt=0;
    rep(j,n){
      if(bit[j]){
        tmp+=a[j];
        tmp_kakeru*=a[j];
        cnt++;
      }
    }
    if(cnt>=k)mp[tmp]++;
    if(cnt>=k)mp[tmp_kakeru]++;   
  }
  ll ans=mp.size();
  cout<<ans<<endl;
  return 0;
}
0