WFU 4th 校賽 AK爺兼職計

2021-10-01 08:28:40 字數 608 閱讀 6988

給你乙個數字n,緊接著n個數字a[i],讓你將這些數字拼接起來,使其在所有的拼接組合中它是最大的乙個。例如:n = 3 ,a[0] = 3,a[1] = 2,a[2] = 1,它有6種組合,在所有的組合中,321最大,輸出321

本題不能單純考慮錄入陣列a並從大到小排序,因為有反例:32,4,按值排序的結果為324,但432比這個結果更好。如何實現拼接兩個數字按序排列?方案是用字串拼接。首先用將各個數字作為字串儲存,然後按照任意兩個字串最佳拼接順序排序。例如對兩個字串a,b,a+b>b+a,a在b前對應的數值比b在a前更大,反之亦然,對應的操作就是逆序交換(按照拼接後值判斷a,b的拼接先後順序,最優順序為順序,反之逆序),為此我們需要借助sort,因為它可以自定義排序函式。

int cmp (const string &a,const string &b)
綜上

#includeusing namespace std;

const int n=1e5+10;

int cmp (const string &a,const string &b)

string a[n];

int main()

JSP 4th 編譯指令include

一 include指令 1 將指定的jsp程式或者html檔案包含進來。2 3 jsp engine會在jsp程式的轉換期間先把file屬性設定的檔案包含進來,然後開始執行轉換及編譯的工作。4 舉例testbar.jsp titlebar.jsp如下所示 訪問testbar.jsp,頁面顯示 總結 ...

多校4 櫥櫃

include include include include includeusing namespace std int s1 400100 int s2 400100 struct node struct cmp int main int i,j,m,n while scanf d d n,m...

多校聯合(4)

感覺這次數學題挺多的,這次的資料應該不能說水了,有的卡的確實挺厲害,但覺得有的題還是很無語,比如說那個trouble,二分感覺不超的,就是過不了,不是wa,就是tle,還會mle,乙個簡單的hash就可以過。是不是太卡演算法了。題目 這道題真沒什麼好說的 view code 1 include 2 ...