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 在项目中 ...
随机推荐
- javascript---对象和函数的引用、浅拷贝、深拷贝、递归
1.javascript 对象和函数的引用 <!doctype html> <html lang="en"> <head> <meta c ...
- caffe 代码阅读笔记1
首先查看caffe.cpp里的train函数: // Train / Finetune a model. //训练,微调一个网络模型 int train() { // google的glog库,检查- ...
- java 动态生成类再编译最后代理
package spring.vhostall.com.proxy; public interface Store { public void sell(); } ------------------ ...
- MariaDB与MySQL并存
以下是MariaDB官方文档说明,MariaDB如何安装在已经存在MySQL实例的主机上: https://mariadb.com/kb/en/library/installing-mariadb-a ...
- crontab 格式
- windows上安装db2 spatial extender和ArcSDE的问题
因客户的DB2版本是9.7的版本,所以测试环境也只能安装这个版本,但在ArcSDE的最小支持版本里至少需要V9.7 pack 4的版本,低于这个版本是不行的. 安装DB2和spatial extend ...
- win10下Visual Studio 2015,C++ x64编译zlib
前提安装了visual studio 2015 PS.几乎所有方式,x64的编译都会有点坑,鉴于网上的x86编译方式非常的多,所以不再累赘x86的编译方式 zlib下载源: 官网:http: ...
- Java 获取盘符及分类
import java.io.File; import javax.swing.filechooser.FileSystemView; public class ByteTest { public s ...
- lua入门之二:c/c++ 调用lua及多个函数返回值的获取
当 Lua 调用 C 函数的时候,使用和 C 调用 Lua 同样类型的栈来交互. C 函数从栈中获取她的參数.调用结束后将返回结果放到栈中.为了区分返回结果和栈中的其它的值,每一个 C 函数还会返回结 ...
- Android网络开发之HttpClient
Apache提供HttpClient,它对java.net中的类做了封装和抽象,更适合在Android上开发应用. HttpClient应用开发几个类: 1. ClientConnectionMana ...