前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

VF

作者头像
书童小二
发布2018-09-03 18:25:46
6140
发布2018-09-03 18:25:46
举报
文章被收录于专栏:前端儿

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?

输入There are multiple test cases. Integer S (1 ≤ S ≤ 81).输出The milliard VF value in the point S.样例输入

代码语言:javascript
复制
1

样例输出

代码语言:javascript
复制
10
代码语言:javascript
复制
 
#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;
}

            
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014-11-02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • VF
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档