Advertisement
juanjo12x

UVA_10943_How_do_you_add

Aug 9th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define LL unsigned long long
  17. using namespace std;
  18. const int mod=1000000;  
  19. int dp[110][110];  
  20.  
  21. void ini(){  
  22.     dp[0][0]=1;  
  23.     for(int k=1;k<=100;k++){  
  24.         for(int sum=0;sum<=100;sum++){  
  25.             for(int i=0;i<=sum;i++){  
  26.                 dp[sum][k]+=(dp[i][k-1]);
  27.             }
  28.             dp[sum][k]=dp[sum][k]%mod;
  29.         }  
  30.     }  
  31. }  
  32.  
  33. int main(){  
  34.     ini();  
  35.     int n,k;  
  36.     while(cin>>n>>k && (n||k)){  
  37.         cout<<dp[n][k]<<endl;  
  38.     }  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement