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

Restricted equation 2

Time limit: 1000 ms
Memory limit: 256 MB
Given four positive integers $S,n,L,H$. Count the number of integer solutions of the following equation: $$x_1+x_2+...+x_n=S$$ that satisfy: $$L \le x_i \le H$$ for all $i$ such that $(1 \le i \le n)$ ### Input - Consists of four integers $S,n,L,H$ $(0 \le L \le H \le S,1 \le n \le S \le 10^6)$ . ### Output - Print the answer modulo $10^9+7$. ### Ví dụ Input: ``` 5 3 0 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
Combinatorics
Rating 1800
Solution (1) Solution