Binomial Coefficient
Practice
4 (5 votes)
Combinatorics
Mathematics
Medium
Open
Approved
Problem
60% Success 945 Attempts 30 Points 1s Time Limit 64MB Memory 1024 KB Max Code

Our hero - Maga has been working on a research related to Pascal’s Triangle for about a month. He has recently found a new problematic thing for his research. He has to calculate a big number. But he is very busy. Could you do it for him?

You are given a binomial as this: (a * x + b * y)^n. You have to find the binomial coefficient of x^k * y^(n-k) modulo 10^9+7.

Input:

You are given 4 integers: each space separated integers a, b, n and k.

Output:

Output 1 integer: the binomial coefficient of x^k * y^(n-k) mod (10^9+7).

Constraints:

1 <= a, b <= 100

1 <= n <= 10^6

1 <= k <= min(n,10^5)

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:30
Tags:
Medium
Points:30
Tags:
Medium