设函数 f(k)(n);

则:

  f(1)(n)=1;

  f(2)(n)=f(1)(0)+f(1)(1)+f(1)(2)+...+f(1)(n);

  f(3)(n)=f(2)(0)+f(2)(1)+f(2)(2)+...+f(2)(n);

        . 

        .

        .

  f(k)(n)=f(k-1)(0)+f(k-1)(1)+...+f(k-1)(n);

可预处理。

附代码:

 #include <iostream>
#include <cstring>
using namespace std; int main (){
int n,k;
int f[][];
memset (f,,sizeof f);
for (int i=;i<=;i++)
f[][i]=;
for (int i=;i<=;i++){
for (int j=;j<=;j++){
for (int o=;o<=j;o++)
f[i][j]=(f[i][j]+f[i-][o])%;
}
}
while (cin>>n>>k&&(n+k)){
cout<<f[k][n]<<endl;
}
return ;
}

UVA 10943 How do you add?的更多相关文章

  1. UVA 10943 How do you add? DP

    Larry is very bad at math — he usually uses a calculator, whichworked well throughout college. Unfor ...

  2. UVA 10943 - How do you add? 递推

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  3. UVa 10943 How do you add?【递推】

    题意:给出n,k,问恰好有k个不超过n的数的和为n的方案数有多少 可以隔板法来做 现在有n个小球放到k个盒子里面,盒子可以为空 那么就是n-k+1个缝隙,放上k-1个隔板(k-1个隔板就分成了k份) ...

  4. UVa 10943 (数学 递推) How do you add?

    将K个不超过N的非负整数加起来,使它们的和为N,一共有多少种方法. 设d(i, j)表示j个不超过i的非负整数之和为i的方法数. d(i, j) = sum{ d(k, j-1) | 0 ≤ k ≤ ...

  5. How do you add? UVA - 10943(组合数的隔板法!!)

    题意: 把K个不超过N的非负整数加起来,使它们的和为N,有多少种方法? 隔板法...不会的可以买一本高中数学知识清单...给高中班主任打个广告.... 隔板法分两种...一种是不存在空集 = C(n- ...

  6. 数论 UVA 10943

    这是一道关于组合数和隔板法的数论题目.题目说的是选出k个不同且不大于N的数字进行相加,要求这些数字之和等于N,结果要求输出这样的数有多少组.这里可以将问题利用隔板法来转换,那么题目的叙述可以转换成:这 ...

  7. UVa 10943 全加和

    https://vjudge.net/problem/UVA-10943 题意: 把K个不超过N的非负整数加起来,使得它们的和为N,有多少种方法? 思路: d[i][j]表示用i个数加起来为j的方法数 ...

  8. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  9. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

随机推荐

  1. MVC中一般为什么用IQueryable而不是用IList?用IQueryable比IList好在哪?

    IList(IList<T>)会立即在内存里创建持久数据,这就没有实现"延期执行(deferred execution)",如果被加载的实体有关联实体(associat ...

  2. 设置PlaceHolder的颜色

    input::-webkit-input-placeholder{ color:green; } input::-webkit-input-placeholder { color: #999; } i ...

  3. GitHub好站点

    https://github.com/XingCloud/stream_processor

  4. Linux合并iso

    http://blog.chinaunix.net/uid-20564848-id-74712.html http://www.yopoing.com/2008/01/windows_linux_un ...

  5. poj 2976 Dropping tests

    http://poj.org/problem?id=2976 这道题就是从n个a[i]和b[i]中去掉k个a[i]和[i]使得.最大. #include <cstdio> #include ...

  6. LeeCode(Database)-Customers Who Never Order

    Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL qu ...

  7. windows多线程没那么难

    windows多线程没那么难 作者:vpoet mail:vpoet_sir@163.com 上一博文中我们引入了CreateThread()多线程编程一个简单的例子,事实上我说windows 多线程 ...

  8. 二分图带权最大独立集 网络流解决 hdu 1569

    方格取数(2) Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total S ...

  9. 一张图讲解为什么需要自己搭建自己的git服务以及搭建的途径

    图片信息量有点大.不废话上图 图中的一些链接: gitlab官方安装文档 https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/in ...

  10. MyCat 主键ID自增长配置

    在实现分库分表的情况下,数据库自增主键已无法保证自增主键的全局唯一.为此,MyCat 提供了全局sequence,并且提供了包含本地配置和数据库配置等多种实现方式,实现方式主要有三种:本地文件方式.数 ...