Use Chicken McNugget Theor if you have only 2 reciprocal values. Otherwise, go to the solution Dynamic programming.
16 ( 2, ), 2 5 , , 2a + 5b 2*5 - 2 - 5 = 3. , , .
2 5 : , , 2. :
2k+1 = (2k - 4) + 5
, , , 5.
3 ., , .
, , :
dp[i] = true if we can reach sum i
dp[0] = true, false for the rest
for i = 0 to query_sum:
dp[i] = dp[i] or dp[i - input1] or dp[i - input2] or dp[i - input3]