Colouring balls
Practice
1 (1 votes)
Easy
Problem
50% Success 294 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Alex loves coloring balls. Today he decided to color N balls  that are placed in a line from left to right.Alex has M different types of colors and can color each ball with one of the M colors.He wants to color each ball such that  color of first K balls from left side are distinct and color of first K balls from right side are distinct. Being a maths lover before coloring balls Alex wants to calculate the number of ways to color balls as described above. Help Alex to calculate number of ways modulo \(10^{9}\)+7. Two ways are considered different if atleast one ball has different colors in both ways.

Input 

The input contains three space separated integers N,M and K.

Output

Print number of ways modulo  \(10^{9}\)+7.

Constraints
1 ≤K ≤ M ≤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:20
11 votes
Tags:
Basic ProgrammingOpenApprovedEasyMathamatics
Points:20
18 votes
Tags:
Ad-HocBasic ProgrammingOpenApprovedEasyMathamatics
Points:20
11 votes
Tags:
Ad-HocMathematicsOpenApprovedEasyMathamatics
Editorial

No editorial available for this problem.