Revizia anterioară Revizia următoare
Fişierul intrare/ieşire: | secretsanta.in, secretsanta.out | Sursă | IIOT 2021-22 Runda 2 |
Autor | Ioan Popescu | Adăugată de | |
Timp execuţie pe test | 0.5 sec | Limită de memorie | 65536 kbytes |
Scorul tău | N/A | Dificultate | N/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 10^9 + 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
În fişierul de ieşire secretsanta.out ...
Restricţii
- 1 ≤ Q ≤ 10^5
- 2 ≤ N ≤ 10^5
- 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 2*10^5.
Exemplu
secretsanta.in | secretsanta.out |
---|---|
4 5 6 9 12 | 44 265 133496 176214841 |