Find sum of subsequences when passed to function F

2019-08-25 02:30发布

问题:

Given an array of size N and integer K we need to find the summation of output of all the subsequences of length K when given to function F where Function F is returning sum of the given subsequence * GCD the given subsequence.

Example : Let N=2 and K=1 and array has only two elements [1,2] then here answer is 5 as there are only two subsequence : [1],[2].

Output for subsequence [1] from function F is 1*1 = 1 Output for subsequence [2] from function F is 2*2 = 4

So total is 1+4=5.

How to find it for given array of length N and given integer K where both of them can range upto 10000 and array elements can range upto 50000.

Obviously this sum can be very large so we need to give output as module to very large prime number 998244353.