Find sum of subsequences when passed to function F

血红的双手。 提交于 2019-12-11 22:05:22

问题


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.

来源:https://stackoverflow.com/questions/51684555/find-sum-of-subsequences-when-passed-to-function-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!