#include #include #include #define LL long long using namespace std; vector as; LL P = 1000000000 + 7; LL N, K; vector fermat(1005); LL mocni(LL a, LL b) { LL moc = a; LL vys = 1; while (b > 0) { if (b % 2 == 1) { vys *= moc; vys %= P; } moc *= moc; moc %= P; b /= 2; } return vys; } LL spoc() { LL total = 0; for(LL i = 0; i < as.size(); ++i) { LL a = as[i]; LL k = K - i; if (k < 0) break; //cout << "n nad k" << a << " " << k; LL nFac = 1; if (a != 0 || k != 0) { for (LL nas = a - k + 1; nas <= a; ++nas) { nFac *= nas; nFac %= P; } } //cout << " = " << (nFac * fermat[k]) % P << endl; total += (nFac * fermat[k]) % P; } //cout << total << endl; if (as.size() == K) { //total -= 1; if (total < 0) { total += P; } } return total; } int main() { cin >> N >> K; for (LL i = 0; i < N; ++i) { char c; cin >> c; if (c == '1') { as.push_back(N - i - 1); } } //for (auto&&k : as) { // cout << k << " "; //} //cout << endl; // (K!)^(P - 2) fermat[0] = 1; LL fac = 1; for (LL i = 1; i <= K; ++i) { fac *= i; fac %= P; fermat[i] = mocni(fac, P - 2); } LL fX = spoc(); as.insert(as.begin(),N); LL fXN = spoc(); LL total = fXN - fX; if (total < 0) { total += P; } cout << total << endl; return 0; }