大意就是: 在1到在10的9次方中,找到各个位数和为固定值s的数的个数,

首先我们确定最高位的个数,为1到9;

以后的各位为0,到9;

运用递归的思想,n位数有n-1位数生成

f(n)(s) +=f(n-1)(s-k)(k=0~9)

可以学习背包问题,直接降到一维表示,注意规划方向,从高到底。

package vf;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
// TODO Auto-generated method stub
int n=82;
int dp[]=new int[n]; dp[0]=0;
int total[]=new int[n]; for(int m=1;m<=9;m++)
{
dp[m]=1;
total[m]=1; } for(int i1=1;i1<9;i1++)//每次加一位
{
            for(int j=n-1;j>=1;j--)
{
int ans=0;
for(int k=0;k<=9&&k<j;k++)
{ ans+=dp[j-k]; }
dp[j]=ans; total[j]+=dp[j]; } } Scanner scn=new Scanner(System.in); while(scn.hasNext())
{ int a=scn.nextInt();
if(a==1)
{
System.out.println(total[a]+1);
}
else
{ System.out.println(total[a]); } } } }

nyoj VF函数的更多相关文章

  1. nyoj VF

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

  2. salesforce 零基础学习(六十五)VF页面应善于使用变量和函数(一)常用变量的使用

    我们在使用formula或者validation rules等的时候通常会接触到很多function,这些函数很便捷的解决了我们很多问题.其实很多函数也可以应用在VF页面中,VF页面有时候应该善于使用 ...

  3. salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用

    上一篇介绍VF中常用的变量,此篇主要内容为VF页面可以直接使用的函数,主要包括Date相关函数,Text相关函数,Information相关函数以及logic相关函数,其他相关函数,比如math相关函 ...

  4. GCD nyoj 1007 (欧拉函数+欧几里得)

    GCD  nyoj 1007 (欧拉函数+欧几里得) GCD 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 The greatest common divisor ...

  5. nyoj 0269 VF(dp)

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

  6. C++ 全排列函数 nyoj 366

    C++ STL中提供了std::next_permutation与std::prev_permutation可以获取数字或者是字符的全排列,其中std::next_permutation提供升序.st ...

  7. nyoj 269 VF 动规

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

  8. nyoj 1007 GCD(数学题 欧拉函数的应用)

    GCD 描述 The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b) ...

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

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

随机推荐

  1. Cassandra1.2文档学习(4)——分区器

    参考文档:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/a ...

  2. php验证身份证号码正确性

    发布:JB01   来源:脚本学堂     [大 中 小] 分享一例php代码,用于验证身份证号码的正确性,用到了preg_match.preg_replace函数,有需要的朋友可以参考学习下.本文转 ...

  3. Python多线程启动http.server

    OS: Windows 8.1 with update 关键字:Python3.4, http.server, Thread 例子代码如下: import os from threading impo ...

  4. 4、Hbase

    1).逻辑模型 Hbase 以表的形式存储数据,每个表由行和列组成,每个列属于一个特定的列族. 表中由行和列确定的存储单元称为一个元素,每个元素保存了同一份数据的多个版本,由时间戳来标识.行健是数据行 ...

  5. 【springmvc Request】 springmvc请求接收参数的几种方法

    通过@PathVariabl注解获取路径中传递参数 转载请注明出处:springmvc请求接收参数的几种方法 代码下载地址:http://www.zuida@ima@com/share/1751862 ...

  6. CAShapeLayer--备用

    之前讲过CALayer动画相关知识,再来看看更加复杂的CAShapeLayer相关的动画知识. 普通CALayer在被初始化时是需要给一个frame值的,这个frame值一般都与给定view的boun ...

  7. firefox浏览器删除插件

    打开注册表编辑器([开始菜单]→[运行]或 Win+R快捷键打开运行,输入regedit). 2 点击菜单栏[编辑]→[搜索],或者按 Ctrl + F 快捷键,搜索 MozillaPlugins . ...

  8. javascript中部分不能使用call apply调用来重写的构造函数

      This tests if TypeError is thrown or not when we call a constructor as a normal function.       On ...

  9. javascript和jquery动态创建html元素

    1.javascript创建元素 创建select var select = document.createElement("select");        elect.opti ...

  10. [DP] Rod-cutting problem

    给一个长度为 n 的杆子,切成小段卖出去,价格根据小段的长度不同而不同.下面是一个例子 我们要通过切成小段卖出尽可能高的总价钱.问题是:How to decompose the problem? De ...