雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

排列组合计算第m种组合 STL实现——pku1833

Posted on 2011-03-18 17:19  huhuuu  阅读(330)  评论(0编辑  收藏  举报
G++提交会超时,C++不会超时
View Code
#include<iostream>
#include
<stdio.h>
#include
<string.h>
#include
<algorithm>
using namespace std;

int main()
{
int a[209],n,m,t,i;
scanf(
"%d",&t);
bool use;
while(t--)
{
use
=0;
scanf(
"%d%d",&n,&m);
for(i=0;i<n;i++)
scanf(
"%d",&a[i]);

while(m--) next_permutation(&a[0],&a[n]);

printf(
"%d",a[0]);
for(i=1;i<n;i++)
{
printf(
" %d",a[i]);
}
printf(
"\n");
}
return 0;
}