Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define MOD 666013
- using namespace std;
- int main()
- {
- int n,sum;
- cin>>n>>sum;
- if(sum>=n*9)
- {
- if(n*9==sum)
- {
- cout<<1<<'\n';
- return 0;
- }
- else
- {
- cout<<0<<'\n';
- return 0;
- }
- }
- vector<int> d(sum+1,0);
- d[0]=1;
- for(int i=1;i<=n;++i)
- {
- if(i==n)d[sum]=0;
- for(int j=sum;j>=0;--j)
- {
- auto&c=d[j];
- int l=max(static_cast<int>(0),j-9);
- for(int k=j-1;k>=l;--k)
- c+=d[k],c-=(c>=MOD)*MOD;
- }
- }
- cout<<d[sum];
- return 0;
- }
Add Comment
Please, Sign In to add comment