eolymp
bolt
Try our new interface for solving problems
Məsələlər

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$.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
10 3
2 2 8
Çıxış verilənləri #1
6
Giriş verilənləri #2
5 2
1 2
Çıxış verilənləri #2
13
Giriş verilənləri #3
1000000000 4
2020 322 1488 1337
Çıxış verilənləri #3
462140823
Müəllif Anton Trygub
Mənbə All-Ukrainian Collegiate Programming Contest 2021-2022, II stage