結果

問題 No.1463 Hungry Kanten
ユーザー 大橋佐和大橋佐和
提出日時 2022-05-06 20:44:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 608 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 124,484 KB
最終ジャッジ日時 2023-09-19 09:47:25
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,120 KB
testcase_01 AC 76 ms
71,244 KB
testcase_02 AC 128 ms
77,852 KB
testcase_03 AC 478 ms
77,324 KB
testcase_04 AC 89 ms
76,464 KB
testcase_05 AC 608 ms
124,484 KB
testcase_06 AC 78 ms
71,296 KB
testcase_07 AC 77 ms
71,320 KB
testcase_08 AC 78 ms
71,412 KB
testcase_09 AC 77 ms
71,188 KB
testcase_10 AC 90 ms
76,428 KB
testcase_11 AC 92 ms
76,492 KB
testcase_12 AC 98 ms
76,552 KB
testcase_13 AC 98 ms
76,728 KB
testcase_14 AC 114 ms
77,924 KB
testcase_15 AC 114 ms
77,408 KB
testcase_16 AC 123 ms
78,276 KB
testcase_17 AC 148 ms
80,620 KB
testcase_18 AC 171 ms
78,672 KB
testcase_19 AC 337 ms
95,180 KB
testcase_20 AC 492 ms
105,192 KB
testcase_21 AC 91 ms
76,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

num_set = set()

for i in range(2**n):
    sum_a = 0
    if bin(i).count("1") >= k:

        for j in range(n):
            if i >> j & 1:
                sum_a += a_list[j]

    num_set.add(sum_a)

for i in range(2**n):
    kakeru_a = 1
    if bin(i).count("1") >= k:

        for j in range(n):
            if i >> j & 1:
                kakeru_a = kakeru_a * a_list[j]

    num_set.add(kakeru_a)
num_set.remove(0)
num_set.remove(1)

print(len(num_set))
0