现在的位置: 首页 > 综合 > 正文

Ignatius and the Princess II hdu 1027

2012年11月27日 ⁄ 综合 ⁄ 共 330字 ⁄ 字号 评论关闭
#include <stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
<algorithm>

using namespace std;

int str[11000];

int main( )
{
int N, M, i, j;
while ( scanf("%d%d", &N, &M) != EOF) {
for ( i = 1; i <= N; i++)
str[i
-1] = i; //默认已经是第1小了
int num = 0;
while( num < M - 1 ) {
next_permutation(str, str
+ N);
num
++;
}
printf(
"%d",str[0]);
for(i = 1; i < N; i++)
printf(
" %d",str[i]);
puts(
"");

}
return 0;
}

抱歉!评论已关闭.