Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <climits>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <cctype>
- #include <cassert>
- #include <ctime>
- #include <iostream>
- #include <utility>
- #include <algorithm>
- #include <limits>
- #include <vector>
- #include <string>
- #include <set>
- #include <map>
- #include <list>
- #include <queue>
- #include <deque>
- #include <bitset>
- #include <stack>
- #define mp(x,y) make_pair(x,y)
- #define pb(x) push_back(x)
- #define fs first
- #define sc second
- #define sz(x) (int((x).size()))
- #define all(x) ((x).begin()),((x).end())
- #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
- #define fab(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
- using namespace std;
- const double eps = 1e-10, inf = 1e10;
- typedef long long ll;
- int dp[1010][1010], n, m;
- char s[1100];
- int main()
- {
- //freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- scanf("%d %d\n%s\n", &m, &n, s);
- int inizio = s[0]-'0';
- fab(i,1,n)
- {
- if (i < m)
- {
- dp[i][0] = 1;
- rep(r,i-1) dp[i][0] = (dp[i][0]*2) % 2011;
- dp[i][1] = dp[i][0];
- }
- else
- {
- dp[i][1-inizio] = (dp[i-1][0] + dp[i-1][1]) % 2011;
- dp[i][inizio] = 0;
- fab(j,1,m-1) dp[i][inizio] = (dp[i][inizio] + dp[i-j][1-int(s[j]-'0')]) % 2011;
- }
- }
- printf("%d\n", (dp[n][0]+dp[n][1]) % 2011);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement