report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Permutation problem - FlandreOJ: Flandre Online Judge

Permutation problem

Time limit: 1000 ms
Memory limit: 256 MB
You are given an integer $k$. Count the number of permutation $P$ of length $n$ that for every $1 \le i \le k$, $P_i \neq i$. ### Input - A single line contains 2 integers $n, k$. ### Output - Print the answer, modulo $10^9+7$. ### Constraints - $1 \le k \le n \le 10^5$. ### Example Input: ``` 3 2 ``` Output: ``` 3 ```
Inclusion-exclusion principle
Divisibility
Divisibility 2
Coprime query
GCD pairs counting
Good string pairs
Permutation problem
Restricted equation
Moving through matrix
Restricted equation 2
Binary matrix 2
Permutation Counting 2
Topic
Math
Combinatorics
Rating 1600
Solution (1) Solution