結果

問題 No.1463 Hungry Kanten
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-19 16:09:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 11,020 ms
コンパイル使用メモリ 410,768 KB
実行使用メモリ 25,104 KB
最終ジャッジ日時 2023-09-09 11:28:42
合計ジャッジ時間 13,590 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 8 ms
4,380 KB
testcase_03 AC 65 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 195 ms
25,104 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,388 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 9 ms
4,404 KB
testcase_17 AC 24 ms
5,648 KB
testcase_18 AC 7 ms
4,384 KB
testcase_19 AC 111 ms
13,692 KB
testcase_20 AC 144 ms
16,084 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mul = boost::multiprecision;

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 (1<<j & i){
                x += A[j];
                y *= A[j];
            }
        }
        st.insert(x);
        st.insert(y);
    }

    cout << st.size() << endl;

    return 0;
}
0