7010.Counting Permutations

Time Limit: 1s Memory Limit: 512MB

A permutation of integers $1,2,\ldots,n$ is called beautiful if there are no adjacent elements whose difference is $1$ .

Given $n$ , your task is to count the number of beautiful permutations.

Input Format(From the terminal/stdin)

The only input line contains an integer $n$ .

  • $1 \le n \le 1000$

Output Format(To the terminal/stdout)

Print the number of beautiful permutations of $1,2,\ldots,n$ modulo $10^9+7$ .

Sample Input

Copy
5
 \n

Sample Output

Copy
14
  \n
Source: CSES, Counting Problems, 1075

Submit

请先 登录

© 2025 FAQs