結果

問題 No.1463 Hungry Kanten
ユーザー hirakuhiraku
提出日時 2021-04-02 22:00:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,462 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 10,540 KB
実行使用メモリ 29,084 KB
最終ジャッジ日時 2023-08-25 14:59:02
合計ジャッジ時間 7,145 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,608 KB
testcase_01 AC 20 ms
8,572 KB
testcase_02 AC 85 ms
9,328 KB
testcase_03 AC 1,386 ms
8,672 KB
testcase_04 AC 24 ms
8,720 KB
testcase_05 AC 1,462 ms
29,084 KB
testcase_06 AC 21 ms
8,548 KB
testcase_07 AC 20 ms
8,568 KB
testcase_08 AC 20 ms
8,580 KB
testcase_09 AC 21 ms
8,740 KB
testcase_10 AC 20 ms
8,660 KB
testcase_11 AC 21 ms
8,788 KB
testcase_12 AC 24 ms
8,832 KB
testcase_13 AC 26 ms
8,624 KB
testcase_14 AC 36 ms
8,820 KB
testcase_15 AC 44 ms
8,784 KB
testcase_16 AC 85 ms
9,688 KB
testcase_17 AC 174 ms
11,956 KB
testcase_18 AC 262 ms
9,424 KB
testcase_19 AC 694 ms
18,776 KB
testcase_20 AC 1,296 ms
28,144 KB
testcase_21 AC 21 ms
8,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)  # 総乗(総積)

n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = set()

# bit全探索
for b in range(1 << len(A)):
    # 初期化
    bb = []
    for i, v in enumerate(A):
        if b >> i & 1:
            # bitが立っているときにする処理
            bb.append(v)
    # 1つのパターンについての何か
    if len(bb) >= k:
        pls = sum(bb)
        ans.add(pls)
        mlt = prod(bb)
        ans.add(mlt)
print(len(ans))
0