結果
問題 | No.1463 Hungry Kanten |
ユーザー |
|
提出日時 | 2021-04-29 15:58:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,961 ms / 2,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 33,648 KB |
最終ジャッジ日時 | 2025-06-20 01:37:26 |
合計ジャッジ時間 | 10,622 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
def popcount(x): x = x - ((x >> 1) & 0x55555555) # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x = (x + (x >> 4)) & 0x0f0f0f0f # 8bitごと x = x + (x >> 8) # 16bitごと x = x + (x >> 16) # 32bitごと return x & 0x0000007f N, K = map(int, input().split()) A = list(map(int, input().split())) ans = dict() for a in range(1, 1 << N): if popcount(a) >= K: s , p = 0, 1 for i in range(N): if ((a >> i) & 1): s += A[i] p *= A[i] if s not in ans: ans[s] = True if p not in ans: ans[p] = True print(len(ans))