結果

問題 No.1463 Hungry Kanten
コンテスト
ユーザー wgrape
提出日時 2024-02-06 11:44:41
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 216 ms / 2,000 ms
+ 459µs
コード長 422 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 218 ms
コンパイル使用メモリ 96,112 KB
実行使用メモリ 126,644 KB
最終ジャッジ日時 2026-07-12 09:53:56
合計ジャッジ時間 3,713 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()))

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