Airplane Arrangements
Practice
3.2 (6 votes)
Combinatorics
Easy
Math
Problem
46% Success 369 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

There is an airplane which has n rows from front to back. There will be m people boarding this airplane.

This airplane has an entrance at the very front and very back of the plane.

Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then board the plane one by one starting with person 1. Each person can independently choose either the front entrance or back entrance to enter the plane.

When a person walks into the plane, they will walk directly to their assigned seat. Then, while the seat they’re looking at is occupied, they will keep moving one space in the same direction. A passenger will get angry if they reach the end of the row without finding their assigned seat.

Find the number of ways to assign tickets to the passengers and board the plane without anyone getting angry. Two ways are different if there exists a passenger who chose a different entrance in both ways, or the assigned seat is different. Print this count modulo \(10^9+7\).

Input Format

The first line of input will contain two integers \(n, m\), the number of seats, and the number of passengers, respectively.

Output Format

Print a single number, the number of ways, modulo \(10^9+7\).

Constraints

\(1 \leq m \leq n \leq 1\,000\,000\)

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
23 votes
Tags:
Ad-HocCombinatoricsEasyImplementationMath
Points:20
8 votes
Tags:
CombinatoricsEasyMath
Points:20
29 votes
Tags:
ApprovedCombinatoricsEasyMath