結果

問題 No.1463 Hungry Kanten
ユーザー rlangevinrlangevin
提出日時 2023-01-01 21:43:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 125,252 KB
最終ジャッジ日時 2023-08-17 23:10:42
合計ジャッジ時間 4,466 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,520 KB
testcase_01 AC 72 ms
71,288 KB
testcase_02 AC 97 ms
78,104 KB
testcase_03 AC 228 ms
77,128 KB
testcase_04 AC 78 ms
76,152 KB
testcase_05 AC 379 ms
125,252 KB
testcase_06 AC 72 ms
71,256 KB
testcase_07 AC 72 ms
71,324 KB
testcase_08 AC 72 ms
71,560 KB
testcase_09 AC 71 ms
71,036 KB
testcase_10 AC 79 ms
76,748 KB
testcase_11 AC 84 ms
76,100 KB
testcase_12 AC 84 ms
76,696 KB
testcase_13 AC 81 ms
76,356 KB
testcase_14 AC 88 ms
76,780 KB
testcase_15 AC 88 ms
76,664 KB
testcase_16 AC 98 ms
78,520 KB
testcase_17 AC 117 ms
81,652 KB
testcase_18 AC 100 ms
78,036 KB
testcase_19 AC 215 ms
95,452 KB
testcase_20 AC 269 ms
104,980 KB
testcase_21 AC 79 ms
76,596 KB
権限があれば一括ダウンロードができます

ソースコード

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