結果

問題 No.1463 Hungry Kanten
コンテスト
ユーザー tobusakana
提出日時 2023-09-07 20:30:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 219 ms / 2,000 ms
+ 702µs
コード長 422 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 219 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 126,776 KB
最終ジャッジ日時 2026-07-12 09:31:45
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

def popcnt(x):
    res = 0
    while x:
        res += x & 1
        x >>= 1
    return res
    
ans = set()
for status in range(1 << N):
    if popcnt(status) < K:
        continue
    s = 0
    m = 1
    for i in range(N):
        if (status >> i) & 1:
            s += A[i]
            m *= A[i]
    ans.add(s)
    ans.add(m)

print(len(ans))
    
    
0