Subsequence sum and GCD
问题 I came across this question on a programming challenge about a month ago, but the editorial wasn't released so I am asking it here. There is an Array A of size N. Find the sum * GCD of K length subsequences of A. Example: If A = [1, 2, 3] and K = 2, {1, 2} = 3(sum) * 1(GCD) = 3 {1, 3} = 4(sum) * 1(GCD) = 4 {2, 3} = 5(sum) * 1(GCD) = 5 Ans => 3 + 4 + 5 = 12 回答1: Here it is from scratch (didn't test it thoroughly though): Let C[k, i, d] be the number of all k -length subsequences of A[1..i]