結果

問題 No.1463 Hungry Kanten
ユーザー tobusakanatobusakana
提出日時 2023-09-07 20:30:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 125,120 KB
最終ジャッジ日時 2023-09-07 20:30:41
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,032 KB
testcase_01 AC 73 ms
71,404 KB
testcase_02 AC 119 ms
78,176 KB
testcase_03 AC 219 ms
77,008 KB
testcase_04 AC 74 ms
75,804 KB
testcase_05 AC 349 ms
125,120 KB
testcase_06 AC 66 ms
71,492 KB
testcase_07 AC 67 ms
71,484 KB
testcase_08 AC 67 ms
71,284 KB
testcase_09 AC 72 ms
71,132 KB
testcase_10 AC 80 ms
76,780 KB
testcase_11 AC 82 ms
75,988 KB
testcase_12 AC 83 ms
76,512 KB
testcase_13 AC 83 ms
76,292 KB
testcase_14 AC 88 ms
76,448 KB
testcase_15 AC 87 ms
76,768 KB
testcase_16 AC 95 ms
78,420 KB
testcase_17 AC 113 ms
81,212 KB
testcase_18 AC 95 ms
77,936 KB
testcase_19 AC 219 ms
95,548 KB
testcase_20 AC 265 ms
104,524 KB
testcase_21 AC 74 ms
76,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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