POJ 1664 放苹果
苹果 poj
2023-09-11 14:15:28 时间
放苹果
Time Limit: 1000ms
Memory Limit: 10000KB
This problem will be judged on PKU. Original ID: 166464-bit integer IO format: %lld Java class name: Main
把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。
Input
第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。
Output
对输入的每组数据M和N,用一行输出相应的K。
Sample Input
1 7 3
Sample Output
8
Source
Author
lwx@POJ
解题:这道题目不是求排列,更像是那个整数分解
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 int dp(int m,int n){ 5 if(m == 0 || n == 1) return 1; 6 if(m < n) return dp(m,m); 7 return dp(m-n,n) + dp(m,n-1); 8 } 9 int main(){ 10 int t,m,n; 11 scanf("%d",&t); 12 while(t--){ 13 scanf("%d %d",&m,&n); 14 printf("%d\n",dp(m,n)); 15 } 16 return 0; 17 }
相关文章
- 苹果创始人Wozniak称Macintosh崩溃是微软的IE导致的
- 图谋中国业务 苹果明年在香港建数据中心
- 苹果OS X是如何跑赢Linux桌面的
- 苹果CMS的V10版本后台登录一直提示验证码错误的解决方案
- Java实现 洛谷 P1487 陶陶摘苹果(升级版)
- Java实现 蓝桥杯VIP 算法训练 猴子分苹果
- 在普通PC 电脑上使用VMware虚拟机安装苹果 macOS系统
- 华为OD机试 - 分苹果(Java & JS & Python)
- 苹果开发者账号个人(Individual)、公司(Company/Organization)、企业(Government Organization)账号区别
- 苹果Swift语言中文教程资源汇总
- POJ-1664 放苹果
- 苹果Mac电脑 如何设置Outlook企业邮箱