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