3987 - Amorphis

Created by Luis Manuel Díaz Barón & Frank Arteaga Salgado
Added by frankr (2018-04-05)
Limits
Total Time: 22000 MS | Test Time: 2000 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

Given a set S containing n (1 <= n <= 1000000) different elements, say S = {E1, E2, ..., En}, and an integer k (0 < k < n), we will call an Amorphis-Arrange to an order of the n elements in which the last one of them: En, is placed before the first K of them: E1, E2, ..., Ek.

Example:
S = {A, B, C, D} and K = 2
En = D (last element)

Amorphis-Arranges:
CDAB, CDBA, DABC, DACB, DBAC, DBCA, DCAB, DCBA. See that D is always placed before A and before B, in all 8 of them.
Dado un conjunto S que contiene n (1 <= n <= 1000000) elementos diferentes, sea S={ E1, E2 ..., En}, y un número entero k (0 < k < n), llamaremos Amorphis-Arrange a un ordenamiento de los n elementos en el cual el último de ellos: En, esta colocado antes de los primeros K de ellos: { E1, E2, ..., Ek }.

Ejemplo:
S = {A, B, C, D} y K = 2
En = D (último elemento)
Amorphis-Arranges:
CDAB, CDBA, DABC, DACB, DBAC, DBCA, DCAB, DCBA.
Vea que D siempre se coloca antes de A y antes de B.
Given a set S containing n (1 <= n <= 1000000) different elements, say S = {E1, E2, ..., En}, and an integer k (0 < k < n), we will call an Amorphis-Arrange to an order of the n elements in which the last one of them: En, is placed before the first K of them: E1, E2, ..., Ek.

Example:
S = {A, B, C, D} and K = 2
En = D (last element)

Amorphis-Arranges:
CDAB, CDBA, DABC, DACB, DBAC, DBCA, DCAB, DCBA. See that D is always placed before A and before B, in all 8 of them.

Input specification

A single line containing two space-separated integers n (1 <= n <= 1000000) and k (0 < k < n).
Una sola linea conteniendo dos enteros separados por espacios, n (1 <= n <= 1000000) y k (0 < k < n).
A single line containing two space-separated integers n (1 <= n <= 1000000) and k (0 < k < n).

Output specification

The number of Amorphis-Arranges, modulated by 1e9 + 7 (1000000007).
El total de ordenamientos Amorphis-Arranges que existen.
A single line containing two space-separated integers n (1 <= n <= 1000000) and k (0 < k < n).

Sample input

3 2

Sample output

2

Hint(s)

http://coj.uci.cu/contest/
http://coj.uci.cu/contest/
http://coj.uci.cu/contest/