Powerful dishes
Practice
4 (8 votes)
Algorithms
Binomial coefficients
Eulerian number
Fast fourier transform
Generating functions
Hard
Stirling numbers
Problem
73% Success 1510 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Monica is a chef. Today, she wants to create dishes consisting of n ingredients. x grams of \(i^{\text{th}}\) ingredient has energy \(x^{a_i}\). Use \(0 ^ 0 = 1\). Two dishes are different if the amount of an ingredient differs in them. The energy of a dish is equal to product of energies of individual ingredients. Also, each dish is to be packed in a different container which can afford a weight of upto y grams.

She makes all distinct dishes with weight(= sum of amounts of ingredients) \( \le y\). Find the sum of energies of all the dishes made by her modulo \(10^9 + 7\). Note that an empty dish(one in which all ingredients have amount 0) is also valid.

Input:
The input consists of two lines:

  • The first line contains two integers, n and y
  • The second line contains n space separated integers, \(i^{\text{th}} \) of which is equal to \(a_i\)

Output:
Print only one line containing the sum of energies of all the dishes made by Monica modulo \(10^9 + 7\)

Constraints:

  • \(1 \le n \le 10^5\)

  • \(0 \le a_i \le 10^5\)

  • \( \sum_{i=1}^{n} a_i \le 10^5 \)

  • \(0 \le y \le 10^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
9 votes
Tags:
AlgorithmsFast Fourier transformHard
Points:50
1 votes
Tags:
AlgorithmsFast Fourier transformHard
Points:50
6 votes
Tags:
Permutation and combinationDynamic Programming2D dynamic programmingFast Fourier transformAdvanced AlgorithmsAlgorithmsDivide-and-conquer algorithm