Color the boxes
Practice
3.3 (112 votes)
Basic programming
Basics of implementation
Implementation
Problem
46% Success 32295 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given \(N\) boxes that are kept in a straight line. You are also given \(M\) colors such that (\(M\le N\)). You cannot change the position of boxes. Determine the number of ways to color the boxes such that if you select any \(M\) consecutive boxes then the color of each box is unique.
Since the number could be large, print the answer modulo \(10^9+7\).
Input format
Two space-separated integers \(N\) and \(M\)
Output format
For the provided inputs, print the required answer.
Constraints
\(1 \le M \le N \le10^6\)
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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
273 votes
Points:10
45 votes
Tags:
Basic ProgrammingBasics of ImplementationData Types and Array handlingEasyImplementation
Points:10
12 votes
Tags:
StringBasic ProgrammingImplementation
Editorial
Login to unlock the editorial