The int[] bag describes a bag of non-negative integers. A bag is the same thing as a set, only it may contain repeated elements.
The order of elements in a bag does not matter.
Given two bags A and B, we say that A is a sub-bag of B if A can be obtained by erasing zero or more elements from B.
The weight of a bag is the sum of its elements.
Examples:
The bags (1,2,1,3,1) and (3,1,1,1,2) are the same, but different from the bag (1,2,3,3).
Bags (1,2) and (3,1,1) are sub-bags of the bag (1,2,1,3,1), but bag (1,2,2) is not.
The weight of the bag (1,2,1,3,1) is 1+2+1+3+1=8.
Write a method that will compute how many sub-bags of bag have a prime weight.
|