#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n,k,mod=1000000;
vector<vector<int> > dp(101,vector<int>(101,-1));
int cc(int m,int sum){
if(sum==0&&m==0)return 1;
if(sum<0||m<0)return 0;
if(dp[sum][m]!=-1)return dp[sum][m];
dp[sum][m]=0;
for(int j=0;j<=sum;j++){
dp[sum][m]+=cc(m-1,sum-j);
dp[sum][m]%=mod;
}
return dp[sum][m];
}
int main(){
while(cin>>n>>k){
if(n==0&&k==0)return 0;
cout<<(cc(k,n))%mod<<endl;
}
return 0;
}
#include <vector>
#include <algorithm>
using namespace std;
int n,k,mod=1000000;
vector<vector<int> > dp(101,vector<int>(101,-1));
int cc(int m,int sum){
if(sum==0&&m==0)return 1;
if(sum<0||m<0)return 0;
if(dp[sum][m]!=-1)return dp[sum][m];
dp[sum][m]=0;
for(int j=0;j<=sum;j++){
dp[sum][m]+=cc(m-1,sum-j);
dp[sum][m]%=mod;
}
return dp[sum][m];
}
int main(){
while(cin>>n>>k){
if(n==0&&k==0)return 0;
cout<<(cc(k,n))%mod<<endl;
}
return 0;
}
Comments
Post a Comment