You are given an integer budget and a 2D integer array items, where items[i] = [factor_i, price_i] represents the factor and price of item i.
You can purchase any number of copies of each item as long as the total cost of all purchased items does not exceed budget.
For each purchased copy of item i, you receive one free copy of an item j (where j ≠ i) if factor_i divides factor_j. If no such item j exists, you do not receive a free copy for that purchased item.
Return the maximum total number of items, including both purchased and free copies, that you can obtain.
Constraints:
items.length
items[i] = [factor_i, price_i]
factor_i items.length
price_i
budget
You are given an integer budget and a 2D integer array items, where items[i] = [factor_i, price_i] represents the factor and price of item i.
You can purchase any number of copies of each item as long as the total cost of all purchased items does not exceed budget.
For each purchased copy of item i, you receive one free copy of an item j (where j ≠ i) if factor_i divides factor_j. If no such item j exists, you do not receive a free copy for that purchased item.
Return the maximum total number of items, including both purchased and free copies, that you can obtain.
Constraints:
items.length
items[i] = [factor_i, price_i]
factor_i items.length
price_i
budget