eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Patriotic Painting 2

Patriotic Painting 2

You are given a strip $1 \times n$, consisting of $n$ yellow cells. You will do $k$ operations with this strip. In the $i$-th operation, you must select some \textbf{exactly} $a_i$ consecutive cells of this strip, and paint all of them blue (if the cell was yellow, it will turn blue, and if it was blue, it will remain blue). How many different colorings of the strip can you get? Since this number can be very large, print it modulo $10^9+7$. Two colorings of the strip are considered different if some cell is painted yellow in one of them and blue in the other one. \InputFile The first line contains two integers $n, k$ ($1 \le n \le 10^9, 1 \le k \le 4$). The second line contains $k$ integers $a_1, \ldots ,a_k$ ($1 \le a_i \le n$). \OutputFile Output the number of different colorings of the strip that you can get modulo $10^9+7$.
Ліміт часу 1 секунда
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
10 3
2 2 8
Вихідні дані #1
6
Вхідні дані #2
5 2
1 2
Вихідні дані #2
13
Вхідні дані #3
1000000000 4
2020 322 1488 1337
Вихідні дані #3
462140823
Автор Anton Trygub
Джерело All-Ukrainian Collegiate Programming Contest 2021-2022, II stage