ural 1353. Milliard Vasya's Function

http://acm.timus.ru/problem.aspx?space=1&num=1353

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 int dp[10][82];
 7 void inti()
 8 {
 9     memset(dp,0,sizeof(dp));
10     dp[0][0]=1;
11     for(int i=1; i<=9; i++)
12     {
13         for(int j=0; j<=i*9; j++)
14         {
15             for(int k=0; k<=9; k++)
16             {
17                 if(j-k>=0)
18                 dp[i][j]+=dp[i-1][j-k];
19             }
20         }
21     }
22 }
23 
24 int main()
25 {
26     inti();
27     int n;
28     scanf("%d",&n);
29     if(n==1)
30     {
31         printf("10\n");
32         return 0;
33     }
34     printf("%d\n",dp[9][n]);
35     return 0;
36 }
View Code

 

posted @ 2014-03-28 19:07  null1019  阅读(149)  评论(0编辑  收藏  举报