(全排列)Ignatius and the Princess II -- HDU -- 1027
链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1027
Ignatius and the Princess II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5822 Accepted Submission(s): 3433
"Now I will show you the first problem." feng5166 says, "Given a sequence of number 1 to N, we define that 1,2,3...N-1,N is the smallest sequence among all the sequence which can be composed with number 1 to N(each number can be and should be use only once in this problem). So it's easy to see the second smallest sequence is 1,2,3...N,N-1. Now I will give you two numbers, N and M. You should tell me the Mth smallest sequence which is composed with number 1 to N. It's easy, isn't is? Hahahahaha......"
Can you help Ignatius to solve this problem?
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue> using namespace std; #define N 1100 int main()
{
int n, m; while(scanf("%d%d", &n, &m)!=EOF)
{
int a[N]; for(int i=; i<=n; i++)
a[i] = i; m--; while(m--)
{
next_permutation(a+, a+n+); /// next_permutation(数组名+起始位置,数组名+长度)
} for(int i=; i<=n; i++)
printf("%d%c", a[i], i==n?'\n':' '); }
return ;
}
(全排列)Ignatius and the Princess II -- HDU -- 1027的更多相关文章
- HDU 1027 Ignatius and the Princess II(求第m个全排列)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/10 ...
- HDU - 1027 Ignatius and the Princess II 全排列
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- HDU 1027 Ignatius and the Princess II[DFS/全排列函数next_permutation]
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- HDU 1027 Ignatius and the Princess II(康托逆展开)
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- poj 1027 Ignatius and the Princess II全排列
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- hdu1027 Ignatius and the Princess II (全排列 & STL中的神器)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=1027 Ignatiu ...
- Ignatius and the Princess II(全排列)
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- hdoj 1027 Ignatius and the Princess II 【逆康托展开】
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- hdu Ignatius and the Princess II
Ignatius and the Princess II Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Ja ...
随机推荐
- 从后台读取项目文件在前端iframe中展示
项目中有个需求是: 对于外部提供的前端项目,包含css.js.html.图片等的项目,将这个项目存进数据库,然后iframe中展示html,然后html中引用的js.css等文件 也能从数据库中读取并 ...
- 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)远程的监控工具连接到本地的JVM执行命令
目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...
- django-模板,过滤器
for…in…:跟python中的for…in…是一样的用法 {% for m in modules %} {{ forloop.cpunter }} {{ m }} {% end %} forloo ...
- strongswan
StrongSwan is an open source IPsec-based VPN Solution. It supports both the IKEv1 and IKEv2 key exch ...
- 概率分布之间的距离度量以及python实现
1. 欧氏距离(Euclidean Distance) 欧氏距离是最易于理解的一种距离计算方法,源自欧氏空间中两点间的距离公式.(1)二维平面上两点a(x1,y1)与b(x2,y2)间的欧 ...
- c# 之Web.config
Web.config文件是一个XML文本文件,它用来储存 ASP.NET Web 应用程序的配置信息(如最常用的设置ASP.NET Web 应用程序的身份验证方式), 它可以出现在应用程序的每一个目录 ...
- ajax的post请求方式
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- 解决docker tty窗口太小,命令换行的问题
docker exec -it -e LINES=$(tput lines) -e COLUMNS=$(tput cols) ed08 bash
- Filebeat+Logstash+Elasticsearch测试
安装配置好三个软件使之能够正常启动,下面开始测试. 第一步 elasticsearch提供了restful api,这些api会非常便利,为了方便查看,可以使用postman调用接口. 1.查看Ela ...
- Redis 集群二
[Redis 集群二] 集群的客户端 Redis 集群现阶段的一个问题是客户端实现很少. 以下是一些我知道的实现: redis-rb-cluster 是我(@antirez)编写的 Ruby 实现, ...