以下是引用雨中飞燕在2007-9-8 23:02:29的发言://第三题
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
//freopen("count.in","r",stdin);
//freopen("count.out","w",stdout);
int n;
cin>>n;
int* list=new int[n+10];
int k;
cin>>k;
for(int n1=0;n1<n;++n1)
{
cin>>list[n1];
}
int k1=0;
for(;k1<k;k1++)
{
if(!next_permutation(list,list+n))
{
for(int n1=0;n1<=n;++n1)list[n1]=n1+1;
++n;
}
}
printf("%d",list[0]);
for(int n1=1;n1<n;++n1)
{
printf(" %d",list[n1]);
}
printf("\n");
delete list;
return 0;
}
这样写我原本以为会超时的(要是我自己肯定让这个代码超时),
不过现在都过了

by 雨中飞燕 QQ:78803110 QQ讨论群:5305909



[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url]
http://yzfy.org/
偶也是一样的代码,就这题的输出文件变为.ans,其他都是.out的,
还有那个十进制数也太小了吧,我本来以为n<=10000,有n!个,要搞个高精度的............