結果

問題 No.1463 Hungry Kanten
ユーザー 大橋佐和大橋佐和
提出日時 2022-05-06 19:59:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 122,992 KB
最終ジャッジ日時 2023-09-19 09:08:56
合計ジャッジ時間 5,279 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,108 KB
testcase_01 AC 80 ms
71,264 KB
testcase_02 AC 118 ms
78,184 KB
testcase_03 AC 335 ms
77,080 KB
testcase_04 AC 87 ms
76,384 KB
testcase_05 AC 466 ms
122,992 KB
testcase_06 AC 79 ms
71,232 KB
testcase_07 AC 78 ms
71,372 KB
testcase_08 AC 78 ms
71,224 KB
testcase_09 AC 78 ms
71,456 KB
testcase_10 AC 88 ms
76,668 KB
testcase_11 AC 91 ms
76,320 KB
testcase_12 AC 95 ms
76,840 KB
testcase_13 AC 90 ms
76,460 KB
testcase_14 AC 102 ms
76,720 KB
testcase_15 AC 96 ms
76,696 KB
testcase_16 AC 111 ms
78,648 KB
testcase_17 AC 136 ms
80,536 KB
testcase_18 AC 128 ms
78,020 KB
testcase_19 AC 278 ms
95,844 KB
testcase_20 AC 375 ms
103,388 KB
testcase_21 AC 90 ms
76,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

num_set = set()
for i in range(1 << k - 1, 1 << n):
    if bin(i).count("1") < k:
        continue
    s = 0
    p = 1
    for j in range(n):
        if i >> j & 1:
            s += a[j]
            p *= a[j]
    num_set.add(s)
    num_set.add(p)

print(len(num_set))
0