# VF

## VF

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 Nth VF in the point S is an amount of integers from 1 to N that have the sum of digits S. You seem to be great programmers, so Vasya gave you a task to find the milliard VF value (i.e. the VF with N = 109) because Vasya himself won’t cope with the task. Can you solve the problem?

`1`

`10`
```
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <memory.h>
#include <string>
#include <math.h>
using namespace std;
int arr[9][81];
int main()
{
int n;
for(int i=1;i<=9;i++)
arr[1][i] = 1;

for(int i=1;i<=9;i++)
for(int j=1;j<=9*i;j++)
for(int k=0;k<=9 && k<=j;k++)
arr[i][j] += arr[i-1][j-k];

while(cin>>n)
{
if(n==1)
{
cout<<10<<endl;
continue;
}

int sum = 0;
for(int i=1;i<=9;i++)
sum += arr[i][n];
cout<<sum<<endl;
}
return 0;
}

```

233 篇文章31 人订阅

0 条评论

## 相关文章

### HDU 5877 2016大连网络赛 Weak Pair(树状数组，线段树，动态开点，启发式合并，可持久化线段树)

Weak Pair Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144...

40210

3536

1961

### Java_数据交换_JAXB_用法入门

JAXB（Java Architecture for XML Binding) 是一个业界的标准，是一项可以根据XML Schema产生Java类的技术。该过程...

1143

### Educational Codeforces Round 44 (Rated for Div. 2)A. Chess Placing

You are given a chessboard of size 1 × n. It is guaranteed that n is even. The c...

1282

### 深入分析Spring MVC中RequestBody与ResponseBody

在SpringMVC中，可以使用@RequestBody和@ResponseBody两个注解，分别完成请求报文到对象和对象到响应报文的转换。在Sprin...

2791

### 聊聊storm的GraphiteStormReporter

storm-core-1.2.2-sources.jar!/org/apache/storm/metrics2/reporters/GraphiteStormR...

1441

### Gym 100952D&&2015 HIAST Collegiate Programming Contest D. Time to go back【杨辉三角预处理，组合数，dp】

D. Time to go back time limit per test：1 second memory limit per test：256 megaby...

2966

### HDUOJ----(1030)Delta-wave

Delta-wave Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K...

3497

### 【笔记】实现一个简易的Promise

const PENDING_STATE = "pending"; const FULLFILL_STATE = "fullfilled"; const REJE...

3314