当前位置:网站首页>HZOJ #236. Recursive implementation of combinatorial enumeration
HZOJ #236. Recursive implementation of combinatorial enumeration
2022-07-07 12:50:00 【Duange】
subject :236. Recursive implementation of combinatorial enumeration
Subject portal :236 topic
Title Description
from 1−n1−n this nn Random selection of integers mm individual , The numbers in each scheme are arranged from small to large , Output all possible options in dictionary order .
Input
Enter two integers n,mn,m.(1≤m≤n≤10)(1≤m≤n≤10)
Output
Each line has a set of schemes , The two numbers in each group are separated by spaces .
Note that there is no space after the last number in each line .
The sample input
3 2
Sample output
1 2
1 3
2 3
The sample input 2
5 3
Sample output 2
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5
Code
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n, m, num[15];
void func(int start, int left, int ind)
{
if (left == 0)
{
for (int i = 0; i < m; i++)
{
if (i) cout << " ";
cout << num[i];
}
cout << endl;
return;
}
for (int i = start; i <= n; i++)
{
num[ind] = i;
func(i + 1, left - 1, ind + 1);
}
}
int main()
{
cin >> n >> m;
func(1, m, 0);
return 0;
}
边栏推荐
- 在字符串中查找id值MySQL
- leetcode刷题:二叉树22(二叉搜索树的最小绝对差)
- 【从 0 开始学微服务】【00】课程概述
- Routing strategy of multi-point republication [Huawei]
- Day-14 common APIs
- BGP actual network configuration
- [learn microservice from 0] [01] what is microservice
- [crawler] avoid script detection when using selenium
- JS to convert array to tree data
- Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
猜你喜欢

Multi row and multi column flex layout

visual stdio 2017关于opencv4.1的环境配置

【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移

【统计学习方法】学习笔记——第五章:决策树

Common knowledge of one-dimensional array and two-dimensional array

Day-19 IO stream

Cookie

图形对象的创建与赋值
![[pytorch practice] use pytorch to realize image style migration based on neural network](/img/20/8ed7113115709b6169be289b0c280a.png)
[pytorch practice] use pytorch to realize image style migration based on neural network

【PyTorch实战】用RNN写诗
随机推荐
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
用mysql查询某字段是否有索引
广州市召开安全生产工作会议
处理链中断后如何继续/子链出错removed from scheduling
leetcode刷题:二叉树24(二叉树的最近公共祖先)
【二叉树】删点成林
图形对象的创建与赋值
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
Object. Simple implementation of assign()
聊聊Redis缓存4种集群方案、及优缺点对比
Customize the web service configuration file
[learn micro services from 0] [02] move from single application to service
利用栈来实现二进制转化为十进制
[pytorch practice] use pytorch to realize image style migration based on neural network
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
普乐蛙小型5d电影设备|5d电影动感电影体验馆|VR景区影院设备
[difficult and miscellaneous]pip running suddenly appears modulenotfounderror: no module named 'pip‘
Day-20 file operation, recursive copy, serialization
图像像素读写操作
通讯协议设计与实现