您的位置:首页 > 其它

Ignatius and the Princess II hdu 1027

2011-08-26 02:08 351 查看
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: