1833 深坑 TLE 求解

2021-09-20 02:02:33 字數 1576 閱讀 9079

題目描述: 

大家知道,給出正整數n,則1到n這n個數可以構成n!種排列,把這些排列按照從小到大的順序(字典順序)列出,如n=3時,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六個排列。 

任務描述: 

給出某個排列,求出這個排列的下k個排列,如果遇到最後乙個排列,則下1排列為第1個排列,即排列1 2 3…n。 

比如:n = 3,k=2 給出排列2 3 1,則它的下1個排列為3 1 2,下2個排列為3 2 1,因此答案為3 2 1。 

input

第一行是乙個正整數m,表示測試資料的個數,下面是m組測試資料,每組測試資料第一行是2個正整數n( 1 <= n < 1024 )和k(1<=k<=64),第二行有n個正整數,是1,2 … n的乙個排列。

output

對於每組輸入資料,輸出一行,n個數,中間用空格隔開,表示輸入排列的下k個排列。

#include//前n次的**#include

intmain()

while(k--)

for(int i=0;i)

printf("\n

");}return0;

}

#include//以為調函式耽誤時間,我就手寫了乙個#include

//結果還是超時 55555#include

using

namespace

std;

int aa[1100

],j;

int comp(const

void*a,const

void*b)

inline

void perm(int *aa)

}int qq, ma=999999999

;

int y=0

;

for(int q=t+1;q)

}if(y)

if(!y)qsort(aa+t,j,sizeof(int

),comp);

}int

main()

for(int i=0;i)

printf(

"%d

",aa[i]);

printf("\n

");}return0;

}

#include//以為大神的能過,原始碼tle  

using

namespace

std;

int n,k,step[1100]; char

lock[1100

];

void f(int

d)

for(;step[d]<=n;step[d]++)

if(!lock

[step[d]])

step[d]=1

; }

intmain()

return

0;

}

python深坑集錦 super

一 前言 python 物件導向中有繼承這個概念,初學時感覺很牛逼,裡面也有個super類,經常見到,最近做一些題才算是理解了。特地記錄分享給後來研究的小夥伴,畢竟現在小學生都開始學了 滑稽臉 二 直接上乾貨,能把下面乙個問題全答對,後面就不用看了。class a def go self print...

php的又一深坑

請大家看如下 並猜想結果會是什麼樣的?arrdata array va info array array position 290,item 70009 array position 290,item 70009 array position 290,item 70009 array positio...

TL10F ASEMI迷你貼片橋堆TL10F

tl10f asemi迷你貼片橋堆 tl10f 型號 tl10f 品牌 asemi 封裝 tlf 4 電性引數1a 1000v 正向電流 1a 反向耐壓 1000v 引腳數量 4 晶元個數 4 晶元尺寸 50mil 封裝尺寸 如圖 特性 貼片整流橋 浪湧電流 30a 工作溫度 50 150 整流橋 ...