[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 ...
随机推荐
- 产品代码都给你看了,可别再说不会DDD(三):战略设计
这是一个讲解DDD落地的文章系列,作者是<实现领域驱动设计>的译者滕云.本文章系列以一个真实的并已成功上线的软件项目--码如云(https://www.mryqr.com)为例,系统性地讲 ...
- 10、Spring之AOP概述
10.1.概念 AOP(Aspect Oriented Programming)是一种设计思想,是软件设计领域中的面向切面编程 AOP是面向对象编程(OOP)的一种补充和完善,OOP是纵向继承机制,A ...
- 通过API接口获取到数据后的使用方法以及储存方法
API接口是许多应用程序和服务所必需的,可以将多个应用程序连接起来,允许不同应用程序之间的数据共享.在本文中,我们将探讨如何使用API接口获取数据,以及如何储存这些数据. 1.使用API接口获取数据 ...
- MySQL允许远程登录的授权方法
泛授权方式 数据库本地直接登录上数据库: mysql -h localhost -u root 然后执行以下命令,授权完后直接就可以远程连接上.mysql>GRANT ALL PRIVILEGE ...
- Solidity-变量和数据类型[基本类型]
在solidity语言中,变量和数据类型分为三类:基本类型(bool.int.address等),复合类型(array.struct.mapping等)和特殊类型(enum.function.modi ...
- 用一个示例来学习DockerFile
在Docker的世界里,我们经常会听到Dockerfile这个词.那么,什么是Dockerfile?它如何工作?本文将简要介绍Dockerfile的基本概念,原理以及一些常用的Dockerfile命令 ...
- 什么是IP协议?
简介: IP(Internet Protocol)协议,又称网际协议,是TCP/IP协议的核心.它负责Internet上网络之间的通信,并规定了将数据报从一个网络传输到另一个网络所应遵循的规则.具体来 ...
- MD5&MD5盐值加密到BCryptPasswordEncoder
MD5&MD5盐值加密 Message Digest algorithm5,信息摘要算法: 压缩性:任意长度的数据,算出的MD5值长度都是固定的 容易计算:从原数据计算出MD5值很容易 抗修改 ...
- python基础:元组(tuple)列表(list)介绍
一,元组 1.元组的创建(可以把元组看作一个容器,任何数据类型都可以放在里面)通过赋值方法创建元组In [5]: t = ("hello",2.3,2,True,{1:" ...
- Destoon模板存放及调用规则
一.模板存放及调用规则 模板存放于系统 template 目录,template 目录下的一个目录例如 template/default/ 即为一套模板模板文件以 .htm 为扩展名,可直接存放于模板 ...