eolymp
bolt
Try our new interface for solving problems
Məsələlər

Never drink too much!

Never drink too much!

Zaman məhdudiyyəti 2 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB

Mahmoud together with his friends visited Georgia. They would stay ina hotel at Rustavelli. When the cowboys reached the hotel, they hung theirhats in the entrance and settled in. The beer bottles on the table could notescape from Mahmoud's attention when passing through the corridor. At thesuggestion of Mahmoud, all the cowboys began drinking. They drank toomuch, thus none of them was mindful. Then they decided going downtown.On the way out, everyone had a hat on, but they mixed up the hats as theywere so drunk.

The man who is able to have on his own hat while he is drunk is consideredclever and who is not able to do so is considered stupid.

You are given the number of cowboys - n (including Mahmoud). Youshould find in how many ways the cowboys may have on the hats so that allof them are stupid. Two ways are considered different if there is at least onecowboy who has a hat in this case and another hat in the other case.

As the answer may become very large, you should output the resultmodulo 10^9 + 7.

Giriş verilənləri

Given the number of cowboys - n (1 ≤ n ≤ 10^7).

Çıxış verilənləri

The answer to the problem as specified above.

Nümunə

Giriş verilənləri #1
1
Çıxış verilənləri #1
0
Giriş verilənləri #4
4
Çıxış verilənləri #4
9
Müəllif Rashad Mammadov
Mənbə EJOI Team Selection - 2018