MCPcopy Create free account
hub / github.com/LeadCoding/3-weeks-Google-Prep / main

Function main

02. Dynamic Programming/3. Digit DP-MagicNumbers.cpp:32–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32int32_t main() {
33 int d,m;
34 cin>>m>>d;
35 string a,b;
36 cin>>a>>b;
37 memset(dp,-1,sizeof dp);
38 int ans=func(b,0,0,d,m,0);
39 memset(dp,-1,sizeof dp);
40 ans-=func(a,0,0,d,m,0);
41 ans+=mod;
42 ans%=mod;
43 int flag=1;
44 int rem=0;
45 for(int i=0;i<a.size();i++) {
46 rem*=10;
47 rem+=(a[i]-'0');
48 rem%=m;
49 if((i%2&&(a[i]-'0'!=d))||((i%2==0)&&(a[i]-'0'==d)))flag=0;
50 }
51 ans+=(flag&&rem==0);
52 cout<<ans%mod;
53
54}

Callers

nothing calls this directly

Calls 1

funcFunction · 0.85

Tested by

no test coverage detected