Pagini recente » Cod sursa (job #3321218) | Cod sursa (job #3320284) | Cod sursa (job #3315119) | Cod sursa (job #3313230) | Cod sursa (job #3336753)
#include <fstream>
#include <cstring>
using namespace std;
const int NMAX = 202, KMAX = 101, MOD = 30103;
ifstream fin("diviz.in");
ofstream fout("diviz.out");
int k, a, b, x, modcrt, sol,
dp[NMAX][KMAX], temp[NMAX][KMAX],
ult[10][NMAX][KMAX], nrc, mod, i;
char n[NMAX];
int main()
{
fin >> k >> a >> b >> n;
int lg = strlen(n);
for(i = 1; i <= lg; ++i)
{
x = n[i - 1] - '0';
if(x) temp[1][x % k] = (temp[1][x % k] + 1) % MOD;
for(nrc = 1; nrc < i; ++nrc)
for(mod = 0; mod < k; ++mod)
if(dp[nrc][mod])
{
modcrt = (mod * 10 + x) % k;
temp[nrc + 1][modcrt] = (temp[nrc + 1][modcrt] + dp[nrc][mod]) % MOD;
}
for(nrc = 1; nrc <= i; ++nrc)
for(mod = 0; mod < k; ++mod)
{
dp[nrc][mod] = (dp[nrc][mod] + temp[nrc][mod] - ult[x][nrc][mod] + MOD) % MOD;
ult[x][nrc][mod] = temp[nrc][mod];
temp[nrc][mod] = 0;
}
}
for(nrc = a; nrc <= b; ++nrc) sol = (sol + dp[nrc][0]) % MOD;
fout << sol;
return 0;
}