結果

問題 No.1463 Hungry Kanten
ユーザー O2MTO2MT
提出日時 2021-04-15 21:35:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 459 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 147,128 KB
最終ジャッジ日時 2023-09-14 23:37:04
合計ジャッジ時間 4,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,576 KB
testcase_01 AC 68 ms
71,236 KB
testcase_02 AC 107 ms
78,240 KB
testcase_03 AC 344 ms
77,492 KB
testcase_04 AC 78 ms
76,396 KB
testcase_05 AC 459 ms
147,128 KB
testcase_06 AC 69 ms
71,252 KB
testcase_07 AC 70 ms
71,436 KB
testcase_08 AC 68 ms
71,376 KB
testcase_09 AC 68 ms
71,376 KB
testcase_10 AC 79 ms
76,584 KB
testcase_11 AC 82 ms
76,212 KB
testcase_12 AC 91 ms
76,964 KB
testcase_13 AC 82 ms
76,424 KB
testcase_14 AC 98 ms
77,956 KB
testcase_15 AC 90 ms
76,988 KB
testcase_16 AC 107 ms
78,716 KB
testcase_17 AC 131 ms
81,556 KB
testcase_18 AC 128 ms
78,704 KB
testcase_19 AC 282 ms
106,416 KB
testcase_20 AC 369 ms
117,508 KB
testcase_21 AC 78 ms
76,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
A = list(map(int,input().split()))
ansSet = set()
for b in range(2**N):
    bit = bin(b)[2:].zfill(N)
    if bit.count('1') < K:
        continue
    s,x = 0,1
    for i in range(len(bit)):
        if bit[i] == '1':
            s += A[i]
            x *= A[i]
    ansSet.add(s)
    ansSet.add(x)
ansList = list(ansSet)
print(len(ansList))
0