nyoj VF函数
大意就是: 在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函数的更多相关文章
- nyoj VF
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make ...
- salesforce 零基础学习(六十五)VF页面应善于使用变量和函数(一)常用变量的使用
我们在使用formula或者validation rules等的时候通常会接触到很多function,这些函数很便捷的解决了我们很多问题.其实很多函数也可以应用在VF页面中,VF页面有时候应该善于使用 ...
- salesforce 零基础学习(六十六)VF页面应善于使用变量和函数(二)常用函数的使用
上一篇介绍VF中常用的变量,此篇主要内容为VF页面可以直接使用的函数,主要包括Date相关函数,Text相关函数,Information相关函数以及logic相关函数,其他相关函数,比如math相关函 ...
- GCD nyoj 1007 (欧拉函数+欧几里得)
GCD nyoj 1007 (欧拉函数+欧几里得) GCD 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 The greatest common divisor ...
- nyoj 0269 VF(dp)
nyoj 0269 VF 意思大致为从1-10^9数中找到位数和为s的个数 分析:利用动态规划思想,一位一位的考虑,和s的范围为1-81 状态定义:dp[i][j] = 当前所有i位数的和为j的个数 ...
- C++ 全排列函数 nyoj 366
C++ STL中提供了std::next_permutation与std::prev_permutation可以获取数字或者是字符的全排列,其中std::next_permutation提供升序.st ...
- nyoj 269 VF 动规
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make a ...
- nyoj 1007 GCD(数学题 欧拉函数的应用)
GCD 描述 The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b) ...
- nyoj 269——VF——————【dp】
VF 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 Vasya is the beginning mathematician. He decided to make ...
随机推荐
- 前端资源多个产品整站一键打包&包版本管理(四)—— js&css文件文件打包并生成哈希后缀,自动写入路径、解决资源缓存问题。
问题: 当我们版本更新的时候,我们都要清理缓存的js跟css,如何使得在网页中不需要手动清理呢? 答案: 生成带有哈希后缀的js跟css文件 1.文件路径 路径中的conf.js 是用于放置全局打包的 ...
- 将TIBCO Host 实例注册为Windows服务
安装了TIBCO ActiveMatrix BPM及成功创建了ActiveMatrix Administrator 和 BPM Server后,每次都要手动启动tibcohost,比较麻烦,实际上TI ...
- python编程语言 函数的形参
python编程语言 函数的形参的讲解: 我在交互模式中写了个函数: def adder(**args): sum=0 for x in args.keys(): sum+=args[x] retur ...
- hdu 4550 卡片游戏 贪心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4550 题意:有n(n <= 100)个0~9之间的卡片,从左往右将卡片放到之前的卡片最左边或者最 ...
- org.springframework.web.servlet.view.InternalResourceViewResolver
http://blog.csdn.net/superdog007/article/details/28857495 我们在controller里面经常这样return一个ModelAndView: r ...
- JQ+AJAX实现多级联动
利用JQ与AJAX实现三级联动实现的效果: 当前两级改变时,后边一级或两级都会改变: 使用的数据库: html代码: <!doctype html> <html lang=" ...
- swift-UILabel
// Mark: 2. 创建label private func creatLabel(title: NSString)->UILabel{ /// 创建label let titleL = U ...
- css3 旋转出现动画
@-moz-keyframes daf{ 0% { -moz-transform: rotate(-360deg) scale(0.2); -webkit-transform: rotate(-360 ...
- How to Cracked Sublime Text 3 Build 3065 in Ubuntu (Linux)
整理自How to Cracked Sublime Text 3 Build 3065 in Ubuntu (Linux) Sublime Text 3 Build 3065 Release Date ...
- flash中函数的理解
flash 中的函数, 只有在调用时,会分配 数据地址(参数数据,返回数据等)和代码地址. 并运行语句,得到结果(返回数据). 结果(返回数据)赋值后 函数调用结束,释放所有建立的所有空间. ---- ...