Fibonacci Numbers of Subset Sums
Time limit5sMemory limit512 MB
Sum F[sum(s)] over all K-element subsets s of a set of N distinct numbers, modulo 99991.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Number theory
- Solved
- No attempts yet
Problem
The Fibonacci numbers are defined as follows.
- ()
You are given a set of numbers and an integer . For every subset of whose size is , take the sum of its elements , and add up over all such subsets. Write a program that computes that total.
For example, take and . The subsets of size 2 are , , , , , , , , , . Their sums are 3, 4, 5, 6, 5, 6, 7, 7, 8, 9 in that order, so the total is .
Input
The first line contains and . (, )
The second line contains the elements of , separated by spaces. Each element is a natural number at most , and the elements are distinct.
Output
Print on the first line the sum of over every subset of size , modulo 99991.