openjudge 百练1664:Placing apples
来源:互联网 发布:matlab与c语言 编辑:程序博客网 时间:2024/06/05 18:21
题目:
Placing apples
View Submit Statistics Hint Clarify
总Time Limit: 1000ms Memory Limit: 65536kB
Description
We are going to place M same apples into N same plates.
There could be some empty plates.
How many methods do we have?
When we have 7 applesand 3 plates, the methods, (1, 5, 1) and (5, 1, 1) are the same.
Input
The first line is the number of test cases, t. 0<=t<=20
The next t lines are test cases containing two numbers, M and N. 1<=M, N<=10.
Output
Output the numbers of method in each test case in one line.
Sample Input
1
7 3
Sample Output
8
代码:
#include <iostream>#include <cstring>#include <cstdio>using namespace std;int ans;int dfs(int m, int n){ if(m==1 || n==1) return 1; if(m<n) return dfs(m, m); else if(m==n) return 1+dfs(m, m-1); else return dfs(m, n-1) + dfs(m-n, n);}int main(){ int t, m, n; cin>>t; while(t--){ cin>>m>>n; cout<<dfs(m, n)<<endl; } return 0;}
好的题解以及关于整数拆分的博客:
http://blog.csdn.net/pi9nc/article/details/8142091
http://blog.chinaunix.net/uid-26548237-id-3503956.html
http://www.cnblogs.com/xiaoxian1369/archive/2011/09/12/2174212.html
https://site.douban.com/191996/widget/notes/11374359/note/262068151/
http://www.cppblog.com/superKiki/archive/2010/05/27/116506.html
- openjudge 百练1664:Placing apples
- Open Judge 1664 Placing apples
- dfs-placing apples
- openjudge 百练 2802 小游戏
- openjudge 百练 熄灯问题
- DSOJ Placing apples(放苹果)
- opj线性表Placing apples 题解
- Poj OpenJudge 百练 2632 Crashing Robots
- Poj OpenJudge 百练 1573 Robot Motion
- Poj OpenJudge 百练 2389 Bull Math
- Poj OpenJudge 百练 2602 Superlong sums
- Poj OpenJudge 百练 1860 Currency Exchang
- OpenJudge 百练 2787 算24
- 水题: OpenJudge (百练 )2807 : 两倍
- 百练openjudge 1050:To the Max
- 【OpenJudge 百练 4118】开餐馆 DP
- [openjudge]百练2755 神奇的口袋
- Poj OpenJudge 百练 Bailian 1008 Maya Calendar
- B - Frequent values
- 制作Linux(Fedora、Ubuntu、CentOS)优盘启动 制作Linux(Fedora、Ubuntu、CentOS)优盘启动
- HDU 4643 GSM(计算几何)
- poj1321
- HttpClient自动处理Gzip,Deflate压缩
- openjudge 百练1664:Placing apples
- 菜鸟入门仿ios高大上--Android沉浸式,复制粘贴动动手
- C#播放器的设计与实现
- 16.7.28
- 安卓转战React-Native之签名打包成Apk并极速多渠道打包
- IE(IE6/IE7/IE8)不兼容HTML5标签的方法
- 手机直播延时直降90% HLS+横空出世
- 块级元素、行内元素、空元素
- HTML5应用之文件拖拽上传