Pagini recente » Cod sursa (job #1757746) | Cod sursa (job #332208) | Cod sursa (job #1990337) | Cod sursa (job #867598) | Cod sursa (job #2047948)
#include <bits/stdc++.h>
#define MOD 30103
using namespace std;
ifstream f("diviz.in");
ofstream g("diviz.out");
int K,A,B,N,Ans;
short DP[201][201][101];
int First[11][201];
char S[202];
int main() {
f>>K>>A>>B>>(S+1);
N=strlen(S+1);
for (int digit=0; digit<=9; digit++) {
for (int position=N; position>=1; position--)
if (S[position]-'0'==digit)
First[digit][position]=position;
else First[digit][position]=First[digit][position+1];
DP[1][First[digit][1]][digit%K]=1; }
for (int lenght=1; lenght<=B; lenght++)
for (int position=lenght; position<=N; position++)
for (int remainder=0; remainder<K; remainder++)
if (DP[lenght][position][remainder]!=0)
for (int newdigit=0; newdigit<=9; newdigit++)
if (First[newdigit][position+1]!=0)
DP[lenght+1][First[newdigit][position+1]][(remainder*10+newdigit)%K]+=DP[lenght][position][remainder],
DP[lenght+1][First[newdigit][position+1]][(remainder*10+newdigit)%K]%=MOD;
for (int lenght=A; lenght<=B; lenght++)
for (int position=lenght; position<=N; position++)
Ans+=DP[lenght][position][0],
Ans%=MOD;
g<<Ans; }