[ABC263C] Monotonically Increasing
Notes
For two integer sequences of the same length $A_1,A_2,\dots,A_N$ and $B_1,B_2,\dots,B_N$, $A$ is said to be lexicographically earlier than $B$ if and only if:
- there is an integer $i$ $(1 \le i \le N)$ such that $A_j=B_j$ for all integers $j$ satisfying $1 \le j < i$, and $A_i < B_i$.
An integer sequence $A_1,A_2,\dots,A_N$ is said to be strictly increasing if and only if:
- $A_i < A_{i+1}$ for all integers $i$ $(1 \le i \le N-1)$.
Constraints
- $1 \le N \le M \le 10$
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
$N$ $M$
Output
Print the sought sequences in lexicographically ascending order, each in its own line (see Sample Outputs).
Sample Input 1
2 3
Sample Output 1
1 2
1 3
2 3
The sought sequences are $(1,2),(1,3),(2,3)$, which should be printed in lexicographically ascending order.
Sample Input 2
3 5
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
爆搜出所有符合要求的排列。
#include<cstdio>
int n,m,st[15];
void dfs(int x,int lst)
{
if(x>n)
{
for(int i=1;i<=n;i++)
printf("%d ",st[i]);
putchar('\n');
return;
}
for(int i=lst+1;i<=m;i++)
{
st[x]=i;
dfs(x+1,i);
}
}
int main()
{
scanf("%d%d",&n,&m);
dfs(1,0);
}
[ABC263C] Monotonically Increasing的更多相关文章
- Application provided invalid, non monotonically increasing dts to muxer in stream
很多同学在使用Ffmpeg过程中都遇到Application provided invalid, non monotonically increasing dts to muxer in stream ...
- Data Structure Array: Longest Monotonically Increasing Subsequence Size
http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/ #include < ...
- [LeetCode] Design Hit Counter 设计点击计数器
Design a hit counter which counts the number of hits received in the past 5 minutes. Each function a ...
- iOS 时间的处理
做App避免不了要和时间打交道,关于时间的处理,里面有不少门道,远不是一行API调用,获取当前系统时间这么简单.我们需要了解与时间相关的各种API之间的差别,再因场景而异去设计相应的机制. 时间的形式 ...
- Apache Kafka – KIP 32,33 Time Index
32, 33都是和时间相关的, KIP-32 - Add timestamps to Kafka message 引入版本,0.10.0.0 需要给kafka的message加上时间戳,这样更方便一些 ...
- LeetCode Design Hit Counter
原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...
- Leetcode: Sort Transformed Array
Given a sorted array of integers nums and integer values a, b and c. Apply a function of the form f( ...
- linux 时间管理——概念、注意点(一)【转】
转自:http://www.cnblogs.com/openix/p/3324243.html 参考:1.http://bbs.eyeler.com/thread-69-1-1.html ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Interpolation in MATLAB
Mathematics One-Dimensional Interpolation There are two kinds of one-dimensional interpolation i ...
随机推荐
- 【故障公告】多年的故障老朋友又来了:数据库服务器 CPU 100%
数据库服务器 CPU 100% 问题几乎每年都要来几次,从来都不事先打一声招呼,今年的第2次在我们正忙着会员救园的时候来了. 今天 13:35 首先收到我们自己的异常告警通知: Execution T ...
- 京东获得JD商品详情 API 返回值说明
item_get-获得JD商品详情 API测试 onebound.jd.item_get 公共参数 名称 类型 必须 描述 key String 是 调用key(必须以GET方式拼接在URL中) ...
- 聊聊HuggingFace如何处理大模型下海量数据集
翻译自: Big data? Datasets to the rescue! 如今,使用大GB的数据集并不罕见,特别是从头开始预训练像BERT或GPT-2这样的Tranformer模型.在这样的情况下 ...
- BeanUtils.copyProperties:曾经是我的女神,现在是我的毒药。
前言 BeanUtils.copyProperties十有八九是你这些年工作中用的很多的其中一个,不管是Apache的还是Spring的. 网上的解释浩如烟海,我这边用一个超简单的例子直观展示给你看. ...
- Java下载多个网络文件并打成压缩包
需求:浏览器访问后台的http地址后,后台将多个网络文件打成压缩包返回给浏览器,用户可以通过浏览器直接下载压缩包. 实现: 根据文件链接把文件下载下来并且转成字节码 ,代码: package com ...
- 小知识:Docker环境缺少vi命令,如何解决
docker exec可以使用--user参数指定root用户,进入安装vi即可: [opc@oci-001 ~]$ docker exec -it --user root testdb bash b ...
- 拉普拉斯金字塔在多图HDR算法中的应用以及多曝光图像的融合算法简介。
在SSE图像算法优化系列二十九:基础的拉普拉斯金字塔融合用于改善图像增强中易出现的过增强问题(一) 一文中我们曾经描述过基于几种高频融合法则的拉普拉斯金字塔融合算法,那里是主要针对2副图像的.实际的应 ...
- MongoDB慢日志
MongoDB慢日志 熟悉 Mysql 的人应该知道,Mysql 是有个慢查询日志的,它可以帮助我们进行优化我们的 sql,并提高我们系统的稳定性和流畅性.那么 MongoDB 中是否也有类似的功 ...
- Abp vNext 模块加载机制
文章目录 生命周期 PreConfigureServices 添加依赖注入或者其它配置之前 ConfigureServices 添加依赖注入或者其它配置 PostConfigureServices 添 ...
- 我试图扯掉这条 SQL 的底裤。
你好呀,我是歪歪. 这次带大家盘一个我觉得有点意思的东西,也是之前写<一个烂分页,踩了三个坑!>这篇文章时,遇到的一个神奇的现象,但是当时忙着做文章搞定这个主线任务,就没有去深究这个支线任 ...