You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
502 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
string s;
int res;
/*
4 3 100
111
81
*/
void dfs(int u, string t) {
if (u == n) {
if (t.find(s) == string::npos) res++;
res = res % k;
return;
}
for (int i = 0; i <= 9; i++) {
t.push_back(i + '0');
dfs(u + 1, t);
t.pop_back();
}
}
int main() {
cin >> n >> m >> k;
cin >> s;
dfs(0, "");
printf("%d\n", res);
return 0;
}