結果
| 問題 | No.1463 Hungry Kanten |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-01-01 21:43:27 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 219 ms / 2,000 ms |
| + 119µs | |
| コード長 | 399 bytes |
| 記録 | |
| コンパイル時間 | 287 ms |
| コンパイル使用メモリ | 96,616 KB |
| 実行使用メモリ | 127,268 KB |
| 最終ジャッジ日時 | 2026-07-12 09:15:57 |
| 合計ジャッジ時間 | 3,868 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
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))
rlangevin