SSL-OI Summer Camp Miscellaneous Problem LOJ#6089 Little Y's Backpack Counting Problem Square Root Decomposition
LOJ 6089 This problem is a miscellaneous problem from the first night of the training camp. Due to my nature of loving to procrastinate, I only came to write the solution in the second week of the training camp. Prerequisite knowledge [Multiple Knapsack]https://www.luogu.com.cn/problem/P1776: Optimized with monotonic queue, achieving complexity. [Integer Partition]https://www.luogu.com.cn/problem/P1025: The number of ways to form integers from integers (with/without repetition), complexity DP. Problem statement Backpack size is , item
LOJ #6089
This problem is a miscellaneous problem from the first night of the training camp. Due to my nature of loving to procrastinate, I only came to write the solution in the second week of the training camp.
Prerequisite Knowledge
Multiple Knapsack: Optimized with monotonic queue, achieving complexity.
Integer Partition: The number of ways to form integers from integers (with/without repetition), complexity DP.
Problem Statement
Backpack size is , number of items is , the weight of the -th item is , and the quantity is .
Question: What is the number of ways to fill the backpack?
Correct Solution
For items greater than , it is equivalent to having no quantity limit. We use integer partition (with repetition) to find the answer.
For items less than , we use multiple knapsack to find the answer. Since the number of items is and the backpack size is , the complexity is .
Comments
0No comments yet.