Pagini recente » Cod sursa (job #2460789) | Cod sursa (job #1396599) | Cod sursa (job #2610624) | Cod sursa (job #590204) | Cod sursa (job #3218407)
#include <fstream>
#include <cstring>
#define mod 30103
using namespace std;
ifstream fin("diviz.in");
ofstream fout("diviz.out");
int k,a,b,ap[201][11],d[2][205][205],sol;
char x[205];
int main()
{
fin>>k>>a>>b;
fin>>x;
int n=strlen(x);
for(int i=n-1;i>=0;i--)
{
for(int c=0;c<=9;c++)
ap[i][c]=ap[i+1][c];
if(i!=n-1)
ap[i][x[i+1]-'0']=i+1;
}
for(int i=1;i<=9;i++){
if(x[0]-'0'==i)
d[0][0][i%k]=1;
else if(ap[0][i]!=0)
d[0][ap[0][i]][i%k]=1;
}
int ind=0;
for(int lg=1;lg<=b;lg++)
{
for(int i=lg-1;i<n;i++)
{
for(int r=0;r<k;r++){
for(int c=0;c<=9;c++)
{
if(ap[i][c]!=0){
d[1-ind][ap[i][c]][(r*10+c)%k]=(d[1-ind][ap[i][c]][(r*10+c)%k]+d[ind][i][r])%mod;
}
}
}
if(lg>=a)
{
if(d[ind][i][0])
sol=(sol+d[ind][i][0])%mod;
}
}
memset(d[ind],0,sizeof(d[ind]));
ind=(1-ind);
}
fout<<sol<<" ";
return 0;
}