ny269 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 题意讲解:本题目是让你求10亿个数的每个位数的数字之和为s的,共有都少个; 例如:和为1的有1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000共有十个; 题意大概就是如此,输入一个S,然后求出和为s,的共有多少个; 可以用动态规划来做: 状态转移方程:
初始条件:dp[0][j]=1 j=1、2…9
状态转移方程:
dp[i][j]表示:和为i,不超过j个数相加的符合条件的数有多少个
dp[i][j]=sum{dp[i-k][j-1] k=0、1…9}
代码如下:
#include<iostream>
using namespace std;
int a[][];
void fun()
{
int sum,n,i,j,k;
for(i=;i<=;i++)
a[][i]=;
for(i=;i<=;i++)
for(j=;j<=;j++)
for(k=;k< && i-k>=;k++)
if(a[i-k][j-])
a[i][j]+=a[i-k][j-];
}
int main()
{
int t;
fun();
while(cin>>t)
{
if(t==)
cout<<<<endl;
else
cout<<a[t][]<<endl;
}
return ;
}
ny269 VF的更多相关文章
- salesforce 零基础学习(二十七)VF页面等待(loading)效果制作
进行查询的情况下,显示友好的等待效果可以让用户更好的了解目前的状态以及减少用户消极的等待,例如下图所示. VF提供了<apex:actionStatus>标签,,此标签用于显示一个AJAX ...
- salesforce 零基础学习(二十六)自定义图表chart简单介绍(使用apex和VF实现)
chart在报表中经常使用到,他可以使报表结果更加直观的展现给用户.salesforce支持VF和apex代码来更好的展示chart. chart分类:常用的图表样式有饼状图,柱状图,折线图,条形图, ...
- nyoj VF函数
大意就是: 在1到在10的9次方中,找到各个位数和为固定值s的数的个数, 首先我们确定最高位的个数,为1到9: 以后的各位为0,到9: 运用递归的思想,n位数有n-1位数生成 f(n)(s) +=f( ...
- 教程-(SQL DBE、ADO连接)+(Firebird火鸟+DbExpress)+(VF DBF数据库)+(DB Paradox)
DBE 连接SQL Server显然用ADO或DBEXPRESS更有优势,起码连接起来比较方便. BDE的话可以用如下方法:(以下以Delphi7为例,其它版本的DELPHI请自己摸索一下,不过基本相 ...
- VF(动态规划)
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make a ...
- rm -vf `ls |egrep -v "info_20130826-180233.31764|QueryParser.INFO"`
> rm -vf `ls |egrep -v "info_20130826-180233.31764|QueryParser.INFO"`
- salesforce 零基础学习(六十五)VF页面应善于使用变量和函数(一)常用变量的使用
我们在使用formula或者validation rules等的时候通常会接触到很多function,这些函数很便捷的解决了我们很多问题.其实很多函数也可以应用在VF页面中,VF页面有时候应该善于使用 ...
- salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用
上一篇介绍VF中常用的变量,此篇主要内容为VF页面可以直接使用的函数,主要包括Date相关函数,Text相关函数,Information相关函数以及logic相关函数,其他相关函数,比如math相关函 ...
- salesforce零基础学习(八十六)Ajax Toolkit (VF页面中使用及javascript action使用)
Ajax Toolkit 参考文档:https://resources.docs.salesforce.com/212/latest/en-us/sfdc/pdf/apex_ajax.pdf 在项目中 ...
随机推荐
- 使用FlashPaper 实现JSP在线阅读[转]
http://cuisuqiang.iteye.com/blog/1841452 使用FlashPaper 实现JSP在线阅读 FlashPaper 是Macromedia推出的一款电子文档类工具,通 ...
- 算法笔记_168:历届试题 矩阵翻硬币(Java)
目录 1 问题描述 2 解决方案 1 问题描述 问题描述 小明先把硬币摆成了一个 n 行 m 列的矩阵. 随后,小明对每一个硬币分别进行一次 Q 操作. 对第x行第y列的硬币进行 Q 操作的定义: ...
- 解决java.sql.SQLException: Incorrect string value: '\xE6\x88\x91\xE7\x9A\x84...' for column 'groupName'
今天使用mysql,用java程序往mysql中写数据,出现如下错误: Caused by: java.sql.SQLException: Incorrect string value: '\xD3\ ...
- 统计一个文件中出现字符'a'的次数
# -*- coding: utf-8 -*- #python 27 #xiaodeng #统计一个文件中出现字符'a'的次数 #http://www.cnblogs.com/hongten/p/ho ...
- 小程序四:视图之WXSS
WXSS(WeiXin Style Sheets)是MINA设计的一套样式语言,用于描述WXML的组件样式. WXSS用来决定WXML的组件应该怎么显示. 为了适应广大的前端开发者,我们的WXSS具有 ...
- 九度OJ 1183 守形数 (模拟)
题目1183:守形数 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2663 解决:1424 题目描写叙述: 守形数是这样一种整数.它的平方的低位部分等于它本身. 比方25的平方是625. ...
- Linux-Linux下安装redis报错"undefined reference to__sync_add_and_fetch_4"解决办法
如果出现这种错误可以在make的时候加上CFLAGS="-march=i686" 即 make CFLAGS="-march=i686" ----------- ...
- jquery checkbox选框操作
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- static不实现多态
class Father { public static String getName() { return "father"; } } class Children extend ...
- js常用点
<span onClick="onDetail(this.id,'edit');" style="cursor: hand;color:black;" ...