Fişierul intrare/ieşire:secretsanta.in, secretsanta.outSursăIIOT 2021-22 Runda 2
AutorIoan PopescuAdăugată destefdascalescuStefan Dascalescu stefdascalescu
Timp execuţie pe test0.5 secLimită de memorie65536 kbytes
Scorul tăuN/ADificultateN/A

Vezi solutiile trimise | Statistici

Secret Santa

Christmas is just around the corner and John's colleagues decided to organize a Secret Santa.

According to Google, Secret Santa is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they give a gift.

There are N students in John's class (him included) and he is very curious to know the number of possible ways Secret Santa can be organized. The number John asks being big, you should output it modulo 109 + 7

Because there are a lot of John's on the planet, you will need to answer Q queries regarding the possible ways Secret Santa can be organized in John's class. A valid way of organizing Secret Santa is a way such that no child gets gifts from two different children and there is no child who has to give a gift to himself/herself.

Date de intrare

The first line of the input file secretsanta.in contains an integer Q, the number of queries.

Each of the following Q lines contains an integer N.

Date de ieşire

The output file secretsanta.out will contain on each line the answer for the corresponding test case.

Restricţii

  • 1 ≤ Q ≤ 105
  • 2 ≤ N ≤ 105
  • For tests worth 10 points, 2 ≤ N ≤ 20.
  • For tests worth another 50 points, the sum of all N in the input doesn't exceed 200.000.

Exemplu

secretsanta.insecretsanta.out
4
5
6
9
12
44
265
133496
176214841
Trebuie sa te autentifici pentru a trimite solutii. Click aici

Cum se trimit solutii?