Pagini recente » Istoria paginii utilizator/filie | Statistici Racolta Victor (racolta) | Cod sursa (job #2190946) | Cod sursa (job #375966) | Cod sursa (job #2018728)
#include<bits/stdc++.h>
#define maxN 205
#define maxK 105
#define mod 30103
using namespace std;
int k,a,b,n,dp[2][maxN][maxK],sol;
char s[maxN];
int main()
{
freopen("diviz.in","r",stdin);
freopen("diviz.out","w",stdout);
scanf("%d%d%d",&k,&a,&b);
scanf("\n");
scanf("%s",s+1);
n=strlen(s+1);
dp[0][0][0]=1;
for(int i=0;i<n;i++)
{
// dp[0][0][0]=1;
for(int j=0;j<=i;j++)
for(int r=0;r<k;r++)
{
dp[1][j+1][(r*10+(s[i+1]-'0'))%k]=(dp[1][j+1][(r*10+s[i+1]-'0')%k]+dp[0][j][r])%mod;
}
for(int j=1;j<=i+1;j++)
for(int r=0;r<k;r++)
{
dp[0][j][r]=(dp[0][j][r]+dp[1][j][r])%mod;
//dp[1][j][r]=0;
}
memset(dp[1],0,sizeof(dp[1]));
}
for(int j=a;j<=b;j++)
sol=(sol+dp[0][j][0])%mod;
printf("%d\n",sol);
return 0;
}