HDU_1027_Ignatius and the Princess II_全排列
Ignatius and the Princess II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6701 Accepted Submission(s):
3964
He opens the door and finds feng5166 is about to kill our pretty Princess. But
now the BEelzebub has to beat our hero first. feng5166 says, "I have three
question for you, if you can work them out, I will release the Princess, or you
will be my dinner, too." Ignatius says confidently, "OK, at last, I will save
the Princess."
"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?
consists of two numbers, N and M(1<=N<=1000, 1<=M<=10000). You may
assume that there is always a sequence satisfied the BEelzebub's demand. The
input is terminated by the end of file.
sequence satisfied the BEelzebub's demand. When output a sequence, you should
print a space between two numbers, but do not output any spaces after the last
number.
11 8
1 2 3 4 5 6 7 9 8 11 10
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std; int a[];
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;i<n;i++)
a[i]=i+;
m--;
while(m--)
{
next_permutation(a,a+n);
}
for(int i=;i<n;i++)
{
if(i!=n-)
printf("%d ",a[i]);
else
printf("%d\n",a[i]);
}
}
return ;
}
HDU_1027_Ignatius and the Princess II_全排列的更多相关文章
- ignitius and princess 2(全排列)
A - Ignatius and the Princess II Now our hero finds the door to the BEelzebub feng5166. He opens the ...
- 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 ( ...
- HDU Ignatius and the Princess II 全排列下第K大数
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include& ...
- 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(求第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[DFS/全排列函数next_permutation]
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 -- HDU -- 1027
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/100 ...
随机推荐
- Android: 长按及松开处理
长按及松开处理 // 长按触发handle final Handler handler = new Handler(); final Runnable mLongPressed = new Runna ...
- 虚拟化(二):虚拟化及vmware workstation产品使用
虚拟化(一):虚拟化及vmware产品介绍 vmware workstation的最新版本号是10.0.2. 相信大家也都使用过,当中的简单的虚拟机的创建.删除等,都非常easy.这里就不再具体说明了 ...
- Test While You Sleep (and over Weekends)
Test While You Sleep (and over Weekends) Rajith Attapattu RELAX. I am not referring to offshore deve ...
- Dynamics CRM Microsoft SQL Server 指定的数据库具有更高的版本号
在做NLB部署时遇到这么个问题,CRMAPP1安装的CRM版本号是6.1已经打了SP1补丁,而在CRMAPP2上的CRM安装包是6.0版本号.在选择连接现有部署后,最后一步检測就出了问题,例如以下图所 ...
- BMP图片的解析,关于压缩方式
在做一个显示bmp图片到lcd屏的时候,发现有些bmp图显示不对. 同样是16bit bmp却有差异. 就查了一下格式. bmp文件格式 位图文件的组成 结构名称 符号 位图文件头(bitmap-fi ...
- JSP页面规格化
http://doc.okbase.net/%E4%BA%BA%E7%94%9F%E9%9A%BE%E5%BE%97%E7%B3%8A%E6%B6%82/archive/123084.html htt ...
- js判断出两个字符串最大子串的函数
<!DOCTYPE html><html><head> <title></title></head><script typ ...
- 等价表达式 2005年NOIP全国联赛提高组(栈模拟)
P1054 等价表达式 题目描述 明明进了中学之后,学到了代数表达式.有一天,他碰到一个很麻烦的选择题.这个题目的题干中首先给出了一个代数表达式,然后列出了若干选项,每个选项也是一个代数表达式,题目的 ...
- bzoj2431: [HAOI2009]逆序对数列(前缀和优化dp)
2431: [HAOI2009]逆序对数列 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 2312 Solved: 1330[Submit][Stat ...
- Gym - 100162G 2012-2013 Petrozavodsk Winter Training Camp G. Lyndon Words 暴力枚举
题面 题意:如果一个字符串的最小表示法是他自己,他就是一个Lyndon Word. 例如 aabcb 他的循环串有 abcba bcbaa cbaab baabc 其中字典序最小的是他自己 现在给 ...