(全排列)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 ...
随机推荐
- DCI改进,发布后作业乱码不能打开
1.发布后作业不能打开问题,找到com.comsys.net.cn.dci.ui.dialog.PublishesDialog 的960行,改为这样: //以前没有指定文件编码前,采用系统默认编码 / ...
- unity的prefab(预设)例子
prefab用于预先设置一些控件,在需要的时候直接引用,简化开发,当然,你完全可以用写代码解决 在场景内新建一个空物体,绑定一个脚本 void Start () { GameObject cube = ...
- Bootstrap-CL:警告
ylbtech-Bootstrap-CL:警告 1.返回顶部 1. Bootstrap 警告(Alerts) 本章将讲解警告(Alerts)以及 Bootstrap 所提供的用于警告的 class.警 ...
- mysql-4连接
联合多表查询 菜鸟教程join 日常应用较多的是从多个表格中获取数据.使用join可以在多个表查询进行select.update.delete. join按照功能分为三类: inner join(内连 ...
- 微信JS接口汇总及使用详解
这篇文章主要介绍了微信JS接口汇总及使用详解,十分的全面.详尽,包含分享到朋友圈,分享给朋友,分享到QQ,拍照或从手机相册中选图,识别音频并返回识别结果,使用微信内置地图查看位置等接口,有需要的小伙伴 ...
- mysql如何处理外码约束
http://hi.baidu.com/wangzhiqing999/item/e74b2be28be445a3c00d7528 MySQL 外键约束 -- 创建测试主表. ID 是主键.CREATE ...
- Golang后台开发初体验
转自:http://blog.csdn.net/cszhouwei/article/details/37740277 补充反馈 slice 既然聊到slice,就不得不提它的近亲array,这里不太想 ...
- Android图片高斯模糊的一些方法
高斯模糊 高斯模糊就是将指定像素变换为其与周边像素加权平均后的值,权重就是高斯分布函数计算出来的值. 一种实现 点击打开链接<-这里是一片关于高斯模糊算法的介绍,我们需要首先根据高斯分布函数计算 ...
- django-聚合操作
聚合操作就是对数据库的数值类型操作的方法 avg,sum,max,min,count select avg(age) from students # 求年龄平均值 django中的聚合操作 1.a ...
- django2.0设置默认访问路由
搭建完毕后,打开域名,直接来个报错,如果没有访问的地址,是不合适的 在urls.py中定义,默认访问的路由 from django.contrib import admin from django.u ...