D - 水之矢 (URAL - 1353 )

Vasya is the beginning mathematician. He decided to make an important contribution to the science and to become famous all over the world. But how can he do that if the most interesting facts such as Pythagor’s theorem are already proved? Correct! He is to think out something his own, original. So he thought out the Theory of Vasya’s Functions. Vasya’s Functions (VF) are rather simple: the value of the N thVF in the point S is an amount of integers from 1 to N that have the sum of digitsS. You seem to be great programmers, so Vasya gave you a task to find the milliard VF value (i.e. the VF with N = 10 9) because Vasya himself won’t cope with the task. Can you solve the problem?

Input

Integer S (1 ≤ S ≤ 81).

Output

The milliard VF value in the point S.

Example

input output
1
10

 

 

#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a;
    int i,j,k,dp[100][100];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(i=0;i<=9;i++)
    {
        for(j=0;j<=9;j++)
        {
            for(k=0;k<=81;k++)
            {
                dp[i+1][k+j]+=dp[i][k];
            }
        }
    }
    dp[9][1]+=1;
    while(cin >> a)
    {
        cout << dp[9][a] << endl;
    }
    return 0;
}

 

上一篇:python获取系统环境变量|os.environ|os.putenv|cmd添加环境变量


下一篇:[转]漫谈虚拟化-计算虚拟化中的 I/O 虚拟化