TCS CodeVita Season 9 Registration is going on Register soon — Click here
TCS CodeVita Previous Year Question must be completed before sitting in the actual round of coding.
Want to know more about TCS Codevita?We have covered a great part of the introduction to TCS CodeVita here you must read this: Click here to open.
Distribute Books
Problem Description
For enhancing the book reading, the school distributed storybooks to students as part of the Children’s day celebrations.
To increase the reading habit, the class teacher decided to exchange books every week so that everyone will have a different book to read. She wants to know how many possible exchanges are possible.
If they have 4 books and students, the possible exchanges are 9. Bi is the book of i-th student and after the exchange he should get a different book, other than Bi.
B1 B2 B3 B4 – first state, before exchange of the books
B2 B1 B4 B3
B2 B3 B4 B1
B2 B4 B1 B3
B3 B1 B4 B2
B3 B4 B1 B2
B3 B4 B2 B1
B4 B1 B2 B3
B4 B3 B1 B2
B4 B3 B2 B1
Find the number of possible exchanges, if the books are exchanged so that every student will receive a different book.
Constraints
1<= N <= 1000000
Input Format
The input contains one line with N, indicates the number of books and the number of students.
Output
Output the answer modulo 1000000007.
Test Case
Explanation
Example 1
Input
4
Output
9
Spread the word and ask your every friend, junior, senior, batchmate, near and dear ones to Register to CodeVita! Click here to register.
Happy Coding!
We will be posting all the questions of CodeVita and also the Mock Tests.
We might not be able to publish all the questions. Keep sending your CodeVita’s question at circuitandcode@gmail.com

0 Comments
We are friendly, helpful and available. Reach out to us anytime and we will happily answer your quires. SEND US A MESSAGE OR FEEDBACK
Emoji