Question 596598
Use ten bags that can hold 1, 2, 4, 8, ..., 512 pieces of candy. This is because every integer has a unique binary representation (e.g. 683 = 1010101111, 512+128+32+8+4+2+1). By using ten bags, you can hold any amount up to 1023 (2^10 - 1) pieces of candy.