Given two natural numbers and , let denote the number of permutations with elements, and such that there are exactly cycles, all them of length at least 2. Implement a dynamic programming code to compute .
Input consists of several cases, each with two natural numbers and . You can assume and .
For every case, print . Because that number can become very large, use @long long@’s and make the computations modulo .
You can compute just adding two “recursive calls”.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T12:22:16.426Z
© Jutge.org, 2006–2026.
https://jutge.org