結果

問題 No.1463 Hungry Kanten
ユーザー Kiri8128Kiri8128
提出日時 2021-04-02 21:30:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 114,608 KB
最終ジャッジ日時 2023-08-25 14:47:07
合計ジャッジ時間 3,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,992 KB
testcase_01 AC 72 ms
71,248 KB
testcase_02 AC 90 ms
76,872 KB
testcase_03 AC 217 ms
76,752 KB
testcase_04 AC 73 ms
75,660 KB
testcase_05 AC 305 ms
114,608 KB
testcase_06 AC 69 ms
70,956 KB
testcase_07 AC 70 ms
71,172 KB
testcase_08 AC 72 ms
71,108 KB
testcase_09 AC 70 ms
70,912 KB
testcase_10 AC 77 ms
76,288 KB
testcase_11 AC 78 ms
76,024 KB
testcase_12 AC 82 ms
76,436 KB
testcase_13 AC 78 ms
75,880 KB
testcase_14 AC 86 ms
76,144 KB
testcase_15 AC 86 ms
76,428 KB
testcase_16 AC 91 ms
77,104 KB
testcase_17 AC 107 ms
80,196 KB
testcase_18 AC 90 ms
76,480 KB
testcase_19 AC 186 ms
93,400 KB
testcase_20 AC 223 ms
101,680 KB
testcase_21 AC 78 ms
76,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(x):
    x -= (x >> 1) & 0x55555555
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x += x >> 8
    x += x >> 16
    return x & 0x3f

N, K = map(int, input().split())
A = [int(a) for a in input().split()]
S = set()
for i in range(1 << N):
    if popcount(i) < K: continue
    s = 0
    t = 1
    for j, a in enumerate(A):
        if i >> j & 1:
            s += a
            t *= a
    S.add(s)
    S.add(t)
print(len(S))
0