nyoj 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?
- 输入
- 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的更多相关文章
- nyoj VF函数
大意就是: 在1到在10的9次方中,找到各个位数和为固定值s的数的个数, 首先我们确定最高位的个数,为1到9: 以后的各位为0,到9: 运用递归的思想,n位数有n-1位数生成 f(n)(s) +=f( ...
- nyoj 0269 VF(dp)
nyoj 0269 VF 意思大致为从1-10^9数中找到位数和为s的个数 分析:利用动态规划思想,一位一位的考虑,和s的范围为1-81 状态定义:dp[i][j] = 当前所有i位数的和为j的个数 ...
- nyoj 269 VF 动规
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make a ...
- nyoj 269——VF——————【dp】
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make ...
- nyoj 269 VF
VF 时间限制:1000 ms | 内存限制:65535 KB 链接:NYOJ269 原创在:点击打开链接 题意:1-1000000000之间,各位数字之和等于给定s的数的个数. 每行给出一个数s ...
- NYOJ 1007
在博客NYOJ 998 中已经写过计算欧拉函数的三种方法,这里不再赘述. 本题也是对欧拉函数的应用的考查,不过考查了另外一个数论基本定理:如何用欧拉函数求小于n且与n互质所有的正整数的和. 记eule ...
- NYOJ 998
这道题是欧拉函数的使用,这里简要介绍下欧拉函数. 欧拉函数定义为:对于正整数n,欧拉函数是指不超过n且与n互质的正整数的个数. 欧拉函数的性质:1.设n = p1a1p2a2p3a3p4a4...pk ...
- NYOJ 333
http://www.cppblog.com/RyanWang/archive/2009/07/19/90512.aspx?opt=admin 欧拉函数 E(x)表示比x小的且与x互质的正整数的个数. ...
- salesforce 零基础学习(二十七)VF页面等待(loading)效果制作
进行查询的情况下,显示友好的等待效果可以让用户更好的了解目前的状态以及减少用户消极的等待,例如下图所示. VF提供了<apex:actionStatus>标签,,此标签用于显示一个AJAX ...
随机推荐
- POJ 2516 Minimum Cost (费用流)
题面 Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area ...
- python数据类型——字符串类型
字符串(string) 字符串,就是字符连成一串,是由字符组成的序列.字符串有编码问题,在之前我已经讲过.本节主要讲字符串的使用. 创建字符串,不用多说: a='123abcd' b='diamond ...
- Android OpenGL ES 开发(八): OpenGL ES 着色器语言GLSL
前面的文章主要是整理的Android 官方文档对OpenGL ES支持的介绍.通过之前的文章,我们基本上可以完成的基本的形状的绘制. 这是本人做的整理笔记: https://github.com/re ...
- node nvm npm nrm 安装
http://cnodejs.org/topic/57f628098489e7ca69f4e839 //1.vim ~./bashrc 文件 把那两行配置代码加进入,然后按步骤执行 //console ...
- static与final的区别
final被修饰的变量为常量一旦赋值不能修改,被修改的方法为最终方法不能被重写,被修饰的类是最终类,不能被继承static被修饰的变量和方法,为该整个类及其类的对象所共享,一个类或对象修改了被定义的类 ...
- 淘宝镜像 cnpm 不是内部命令
升级npm之后安装淘宝镜像,然后一直提示不是内部命令,网上查看文章 http://blog.csdn.net/fighting_2017/article/details/76979844,发现是路径问 ...
- 自动安装L2tp的脚本
来自于 https://teddysun.com/448.html #!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/ ...
- 关于 Touchjs 手势识别事件库 this 关键字与选择器不对称情况
Touchjs 版本 v0.2.14 废话不多,直接看代码,一个拖动实例 <div id="touch-drag"></div> <script ty ...
- IPFS:世界正在悄然发生变化
世界正在悄然发生变化(IPFS) 2015-05-05 Juan Benet 在自己的终端里面敲入了下面的文字: > echo "hello worlds" | ipfs a ...
- python函数式编程之生成器
在前面的学习过程中,我们知道,迭代器有两个好处: 一是不依赖索引的统一的迭代方法 二是惰性计算,节省内存 但是迭代器也有自己的显著的缺点,那就是 不如按照索引取值方便 一次性,只能向后取值,不能向前取 ...