keep track of items in knapsack
greatest common divisor optimization