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 ...
随机推荐
- SVN提交时报错:Commit blocked by pre-commit hook (exit code 1) with no output.
可能的原因: 提交代码的SVN命令中,Comment长度短了.参考:http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-howto-minl ...
- fast recovery area
First of all, the version of my enviroment is Oracle 11.0.2.3. The fast recovery area used to be cal ...
- Solidworks在哪里找到内六角螺钉 内六角螺栓保准件
GB-screws-凹头螺钉-出来了
- 怎样对Android设备进行网络抓包
问题描写叙述: 前段时间自己的app訪问server的url总是会出现间接性失败的问题,于是和server的同事开了个会.提出了他们server存在的这个bug,我的同事自然说自己的server没问题 ...
- ERROR (ConnectionError): HTTPConnectionPool (Caused by <class 'socket.error'>: [Errno 111] Connecti
感谢朋友支持本博客.欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免.欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...
- ORACLE 11G 怎样改动 awr 的保留期限小于8天
ORACLE 11G 怎样改动 awr 的保留期限小于8天 Oracle Database 11g 默认具备一个系统定义的Moving Window Baseline,该基线相应于 AWR 保留 ...
- 2015南阳CCPC A - Secrete Master Plan A.
D. Duff in Beach Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed in a ...
- 关于linux的用户
1 linux支持多个用户 2 每个登陆用户有自己的shell,自己的home目录 3 可以将用户分组 4 用户对文件有各自的权限,从而将用户分割 5 用户对应属于它的一批进程 6 可以执行addus ...
- (C语言版)链表(三)——实现双向链表创建、删除、插入、释放内存等简单操作
上午写了下单向循环链表的程序,今天下午我把双向链表的程序写完了.其实双向链表和单向链表也是有很多相似的地方的,听名字可以猜到,每个节点都包含两个指针,一个指针指向上一个节点,一个指针指向下一个节点.这 ...
- 第四章、TIny4412 U-BOOT移植四 配置时钟频率源码分析【转】
本文转载自:http://blog.csdn.net/eshing/article/details/37542459 版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 上 ...