← RoseCode

ROSECODE 211

Subsets

sinan · Programming ·

Let S be the set of numbers up to 40. S={1,2,..,40} Note the following subsets: S1 is the prime numbers in S. S2 is the semiprime numbers in S. S3 is the all other numbers of S. Now consider 4 subsets all with 4 distinct numbers. A is a subset of S1. B is a subset of S2. C is a subset of S3. D is also a subset of S3 but C and D are disjoint. Find the number of A,B,C, and D subsets such that - they all sum to the same number - the smallest element of A < that of B < that of C < that of D Example: A={5, 19, 23, 37} B={6, 14, 26, 38} C={8, 12, 28, 36} D={16, 18, 20, 30} 5+19+23+37=6+14+26+38=8+12+28+36=16+18+20+30=84 5 < 6 < 8 < 16 This counts as one solution. [My timing: 21s]