大意就是: 在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. 面试题(C#基础)

    1>构造器Constructor不能被继承,因此不能重写Overriding,但可以被重载Overloading. 2>string[] ss=Enum.GetNames(typeof(C ...

  2. Nodejs初学者福音

    Nodejs+Express+MongoDb 搭建个人博客  001 我喜欢把任务或者工作分解成工作流来完成,如下,后面将会按照流程来详述,希望能为Nodejs初学者及推广Nodejs做出些努力. n ...

  3. WPF学习笔记2——XAML之2

    三.事件处理程序与代码隐藏 例如,为一个Page添加一个Button控件,并为该Button添加事件名称Button_Click: <Page xmlns="http://schema ...

  4. java.io.IOException: Cannot run program "bash": error=12, Cannot allocate memory

    java.io.IOException: Cannot run program , Cannot allocate memory 云服务器运行nutch报出的异常: 解决方案: http://daim ...

  5. html5判断用户摇晃了手机(转)

    先来看下html5的这几个特性: 1.deviceOrientation:方向传感器数据的事件,通过监听该事件可以获取手机静态状态下的方向数据: 2.deviceMotion: 运动传感器数据事件,通 ...

  6. round(x[, n]) : 四舍五入

    >>> round(12.3) 12.0 >>> round(12.5) 13.0 >>> round(12.36) 12.0 >>& ...

  7. 九张图让你的PPT立刻高大上

  8. Linux下 config/configure/Configure、make 、make test/make check、sudo make install 的作用

    转自Linux下 config/configure/Configure.make .make test/make check.sudo make install 的作用 这些都是典型的使用GNU的AU ...

  9. Linux下eclipse的安装以及配置

    在安装好jdk并配置好后,就可以进行eclipse的安装了,其步骤如下: 1.下载eclipse 我所用的eclipse为:eclipse-dsl-juno-SR1-linux-gtk.tar 2. ...

  10. flash中函数的理解

    flash 中的函数, 只有在调用时,会分配 数据地址(参数数据,返回数据等)和代码地址. 并运行语句,得到结果(返回数据). 结果(返回数据)赋值后 函数调用结束,释放所有建立的所有空间. ---- ...