VF

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
 
描述
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.
样例输入
1
样例输出
10

#include <iostream>
#include <cstring>
using namespace std;

int dp[10][82];//前i位的和为j
int main()
{
memset(dp,0,sizeof(dp));
for(int i=1;i<10;i++)//当n==1的时候,有1 10 100 1000 -----1000000000这些情况
dp[1][i]=1;

for(int i=1;i<10;i++)//前i位
for(int j=1;j<=i*9;j++)//和为j的情况,最大的是前i位每位的数字都是9
for(int k=0;k<=9&&k<=j;k++)//当第i位为k时
dp[i][j]+=dp[i-1][j-k];//前i位和为j的情况=前i位和为j的情况+前i-1位和为j-k的情况

int n;
while(cin>>n)
{
int sum=0;
if(n==1)
cout<<10<<endl;
else
{
for(int i=1;i<10;i++)
sum+=dp[i][n];
cout<<sum<<endl;
}
}
return 0;
}

nyoj VF的更多相关文章

  1. nyoj VF函数

    大意就是: 在1到在10的9次方中,找到各个位数和为固定值s的数的个数, 首先我们确定最高位的个数,为1到9: 以后的各位为0,到9: 运用递归的思想,n位数有n-1位数生成 f(n)(s) +=f( ...

  2. nyoj 0269 VF(dp)

    nyoj 0269 VF 意思大致为从1-10^9数中找到位数和为s的个数 分析:利用动态规划思想,一位一位的考虑,和s的范围为1-81 状态定义:dp[i][j] = 当前所有i位数的和为j的个数 ...

  3. nyoj 269 VF 动规

    VF 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make a ...

  4. nyoj 269——VF——————【dp】

    VF 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Vasya is the beginning mathematician. He decided to make ...

  5. nyoj 269 VF

    VF 时间限制:1000 ms  |  内存限制:65535 KB 链接:NYOJ269 原创在:点击打开链接 题意:1-1000000000之间,各位数字之和等于给定s的数的个数. 每行给出一个数s ...

  6. NYOJ 1007

    在博客NYOJ 998 中已经写过计算欧拉函数的三种方法,这里不再赘述. 本题也是对欧拉函数的应用的考查,不过考查了另外一个数论基本定理:如何用欧拉函数求小于n且与n互质所有的正整数的和. 记eule ...

  7. NYOJ 998

    这道题是欧拉函数的使用,这里简要介绍下欧拉函数. 欧拉函数定义为:对于正整数n,欧拉函数是指不超过n且与n互质的正整数的个数. 欧拉函数的性质:1.设n = p1a1p2a2p3a3p4a4...pk ...

  8. NYOJ 333

    http://www.cppblog.com/RyanWang/archive/2009/07/19/90512.aspx?opt=admin 欧拉函数 E(x)表示比x小的且与x互质的正整数的个数. ...

  9. salesforce 零基础学习(二十七)VF页面等待(loading)效果制作

    进行查询的情况下,显示友好的等待效果可以让用户更好的了解目前的状态以及减少用户消极的等待,例如下图所示. VF提供了<apex:actionStatus>标签,,此标签用于显示一个AJAX ...

随机推荐

  1. HNOI2008玩具装箱

    斜率优化 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <s ...

  2. DOM节点类型

    DOM1级定义了一个Node接口,该接口将由DOM中的所有节点类型实现.这个Node接口在JavaScript中是作为Node类型实现的:除了IE外,在其他所有浏览器中都可以访问到这个类型.JavaS ...

  3. java微信公众号开发token验证失败的问题及解决办法

    本文引自http://m.blog.csdn.net/qq_32331997/article/details/72885424 微信公众平台服务器配置时,需要引入token,但是提交的时候总是提示to ...

  4. Spring Boot Actutaur + Telegraf + InFluxDB + Grafana 构建监控平台之应用数据分析

    本节将引入完美的granafa仪表板,在上节的基础上,并提出自己的一些监控数据的总结和看法 你可以有一个类似于这个的Dashboard,会引入监控Zimbra协作 本节环境采用的是centos7系统, ...

  5. wim命令删除后重新安装

    个人原创博客,转载请注明,否则追究法律责任 2017-09-30-09:51:20 1,删除vim命令.模拟错误 [root@localhost ~]# which vim/usr/bin/vim[r ...

  6. canvas实现将文字变成颗粒

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  7. 剑指Offer-不用加减乘除做加法

    package Other; /** * 不用加减乘除做加法 * 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. * 思路:位运算 * 1.两个数异或:相当于每一位相加 ...

  8. 1-2 hibernate主配置文件hibernate.cfg.xml详解

    详 http://www.cnblogs.com/biehongli/p/6531575.html Hibernate的主配置文件hibernate.cfg.xml 1:Hibernate的主配置文件 ...

  9. spring cloud 专题二(spring cloud 入门搭建 之 微服务搭建和注册)

    一.前言 本文为spring cloud 微服务框架专题的第二篇,主要讲解如何快速搭建微服务以及如何注册. 本文理论不多,主要是傻瓜式的环境搭建,适合新手快速入门. 为了更好的懂得原理,大家可以下载& ...

  10. python安装第三方库

    在编写爬虫程序时发现unsolved import 一时不解,以为是ide出问题了,其实是没有安装第三方库导致的. 于是到https://pypi.python.org/pypi/requests/去 ...