結果

問題 No.1463 Hungry Kanten
ユーザー rlangevin
提出日時 2023-01-01 21:43:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 370 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 120,776 KB
最終ジャッジ日時 2025-06-20 01:40:48
合計ジャッジ時間 3,728 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n //= 2
    return cnt

N, K = map(int, input().split())
A = list(map(int, input().split()))

SS = set()
for i in range(1 << N):
    if popcount(i) < K:
        continue
    S = 0
    P = 1
    for j in range(N):
        if (i >> j) & 1:
            S += A[j]
            P *= A[j]
    SS.add(S)
    SS.add(P)
print(len(SS))    
0