当前位置:网站首页>放苹果(暑假每日一题 13)
放苹果(暑假每日一题 13)
2022-08-02 11:08:00 【sweetheart7-7】
把 M M M 个同样的苹果放在 N N N 个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?
盘子相对顺序不同,例如 5 , 1 , 1 5,1,1 5,1,1 和 1 , 5 , 1 1,5,1 1,5,1 算作同一种分法。
输入格式
输入包含多组测试数据。
每组数据占一行,包含两个整数 M M M 和 N N N。
输出格式
每组数据,输出一行一个结果表示分法数量。
数据范围
1 ≤ M , N ≤ 10 1≤M,N≤10 1≤M,N≤10
输入样例:
7 3
输出样例:
8
#include<iostream>
using namespace std;
int m, n;
int dfs(int u, int sum, int last){
if(u == n)
return sum == 0;
int res = 0;
for(int i = last; i <= sum; i++)
res += dfs(u + 1, sum - i, i);
return res;
}
int main(){
while(cin >> m >> n)
cout << dfs(0, m, 0) << endl;
return 0;
}
边栏推荐
- Oracle查询提示 ORA-00933 SQL command not properly ended 原因排查
- sva assertion data
- 配置mysql失败了,这是怎么回事呢?
- Oracle 19c 连接PDB
- AlphaFold又放大招,剑指整个生物界!
- Shell编程之条件语句
- Hub and Spoke配置案例
- Multithreading (Basic) - 40,000 word summary
- 【2022 小目标检测综述】Towards Large-Scale Small Object Detection: Survey and Benchmarks
- 【面向校招】Golang面试题合集
猜你喜欢

深度学习100例 —— 卷积神经网络(CNN)实现mnist手写数字识别

Mysql transaction isolation level and MVCC (multi-version concurrency control)

10份重磅报告 — 展望中国数字经济未来
![ASP.NET Core 6框架揭秘实例演示[31]:路由&quot;高阶&quot;用法](/img/57/821576ac28abc8d1c0d65df6a72fa3.png)
ASP.NET Core 6框架揭秘实例演示[31]:路由&quot;高阶&quot;用法

Three.JS程序化建模入门

企业级数据治理工作怎么开展?Datahub这样做

3年测试在职,月薪还不足2w,最近被裁员,用亲身经历给大家提个醒...

字母交换--字符串dp

FinClip | 来了, 2022 年 7 月更新大盘点

OSI 七层模型和TCP/IP模型及对应协议(详解)
随机推荐
ASP.NET Core 6框架揭秘实例演示[31]:路由&quot;高阶&quot;用法
Alibaba CTO Cheng Li: Alibaba Open Source History, Concept and Practice
4年手工测试被应届生取代了,用血与泪的教训给xdm一个忠告,该学自动化了...
AlphaFold又放大招,剑指整个生物界!
Getting Started with Three.JS Programmatic Modeling
FPGA手撕代码——CRC校验码的多种Verilog实现方式 (2021乐鑫科技数字IC提前批代码编程)
突破边界,华为存储的破壁之旅
Challenge LeetCode1000 questions in 365 days - Day 047 Design Circular Queue Circular Queue
Turning and anti-climbing attack and defense
SQLAlchemy使用教程
字母交换--字符串dp
5G基础学习1、5G网络架构、网络接口及协议栈
软件测试岗位巨坑?阿里在职7年测试人告诉你千万别上当
Geoffery Hinton: The Next Big Thing in Deep Learning
3 d laser slam: LeGO - LOAM - ground point extracting method and the analysis of the code
Nanny Level Tutorial: Write Your Own Mobile Apps and Mini Programs (Part 2)
SQL(面试实战07)
What is the future of smartwatches?
Outsourced Student Management System Architecture Documentation
sva assertion data