P1515 Travel

Description

You are going to take a trip of $7000$ kilometers. There are some motels along the way. For safety, you do not drive at night and stay in motels. You already have a list of motels, identified by their distance from the starting point, as follows: - $[0,990,1010,1970,2030,2940,3060,3930,4060,4970,5030,5990,6010,7000]$. However, some motels may be added before departure. To save costs, the travel agency requires that you drive at least $A$ kilometers each day. For safety, the national travel agency requires that you drive at most $B$ kilometers each day. You want to know how many travel plans there are in total.

Input Format

The first line contains an integer $A$. The second line contains an integer $B$. The third line contains an integer $N$ ($0 \le N \le 20$), indicating that $N$ additional motels are added before departure. The next $N$ lines each contain an integer $m$, which is the distance of a motel from the starting point ($0 < m < 7000$). Note: No two motels are at the same location.

Output Format

Output the total number of travel plans.

Explanation/Hint

Translated by ChatGPT 5