結果

問題 No.1463 Hungry Kanten
ユーザー takumattakumat
提出日時 2021-04-09 23:49:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,593 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 28,448 KB
最終ジャッジ日時 2023-09-07 18:47:26
合計ジャッジ時間 6,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,768 KB
testcase_01 AC 16 ms
7,904 KB
testcase_02 AC 71 ms
8,948 KB
testcase_03 AC 1,494 ms
7,788 KB
testcase_04 AC 16 ms
7,904 KB
testcase_05 AC 1,593 ms
28,448 KB
testcase_06 AC 16 ms
7,780 KB
testcase_07 AC 15 ms
7,900 KB
testcase_08 AC 15 ms
7,792 KB
testcase_09 AC 15 ms
7,768 KB
testcase_10 AC 16 ms
7,800 KB
testcase_11 AC 16 ms
7,900 KB
testcase_12 AC 19 ms
8,232 KB
testcase_13 AC 17 ms
7,768 KB
testcase_14 AC 30 ms
8,316 KB
testcase_15 AC 20 ms
7,976 KB
testcase_16 AC 71 ms
9,292 KB
testcase_17 AC 187 ms
11,664 KB
testcase_18 AC 81 ms
8,832 KB
testcase_19 AC 748 ms
18,308 KB
testcase_20 AC 1,068 ms
27,588 KB
testcase_21 AC 18 ms
7,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().strip().split())

ai = [int(i) for i in input().split()]

ans = set()
for bits in range(1 << N):
    if bin(bits).count("1") >= K:
        sum = 0
        mul = 1
        for k in range(N):
            if bits & (1 << k):
                sum += ai[k]
                mul *= ai[k]
        
        ans.add(sum)
        ans.add(mul)

print(len(ans))
0