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 ...
随机推荐
- 【SHOI2012】魔法树(树链剖分,线段树)
[SHOI2012]魔法树 题面 BZOJ上找不到这道题目 只有洛谷上有.. 所以粘贴洛谷的题面 题解 树链剖分之后直接维护线段树就可以了 树链剖分良心模板题 #include<iostream ...
- Angular和Vue.js 深度对比
Vue.js 是开源的 JavaScript 框架,能够帮助开发者构建出美观的 Web 界面.当和其它网络工具配合使用时,Vue.js 的优秀功能会得到大大加强.如今,已有许多开发人员开始使用 Vue ...
- C# 委托Delegate的使用 笔记
使用delegate总是一头雾水,记录一下笔记,备忘. 主要用于线程间操作UI上的控件,以便使用.或者是大家统一操作入口使用. using System.Windows.Forms; namespac ...
- JavaScript 运用ES2015特性的小项目
阅读了<JavaScript Pattern>这本书,里面讲了很多js的本质概念以及项目的设计理念.很值得一看,这是我做的摘要,有兴趣的看官可以点这里.里面讲解mediator patte ...
- ssh框架中struts.xml 的配置参数详解
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "- ...
- oracle、instantclient以及plsql安装包
链接:http://pan.baidu.com/s/1skZidWT 密码:l1hq
- READ TABLE 的用法
SORT ITAB BY '你想比较的列'. " 排序以增加二分查找的速度 READ TABLE itab with key 'itab中某列' = ‘目标列' BINARY SEARCH. ...
- 9.FileWriter 和 BufferWriter
FileWriter 和 BufferWriter的使用场景 http://www.cnblogs.com/xjyh/p/4529809.html
- 笔记:MyBatis XML配置-typeAliases 内建别名表
别名 映射的类型 _byte byte _long long _short short _int int _integer int _double double _float float _boole ...
- POJ-1256 next_permutation函数应用
字典序列: 在字典序中蕴含着一个点,就是大小的问题,谁先出现,谁后出现的问题.譬如a<b<c,出现顺序就是a,b,c. 本题中字符集是所有大小写字母,而题目中规定的谁大谁小已经不是按asc ...