最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1509A - Average Height

2023-07-19 10:36 作者:您是打尖兒還是住店呢  | 我要投稿

Sayaka Saeki is a member of the student council, which has n other members (excluding Sayaka). The i-th member has a height of ai millimeters.


It's the end of the school year and Sayaka wants to take a picture of all other members of the student council. Being the hard-working and perfectionist girl as she is, she wants to arrange all the members in a line such that the amount of photogenic consecutive pairs of members is as large as possible.


A pair of two consecutive members u and v on a line is considered photogenic if their average height is an integer, i.e. au+AV2 is an integer.

Help Sayaka arrange the other members to maximize the number of photogenic consecutive pairs.

Input

The first line contains a single integer t (1≤t≤500) — the number of test cases.


The first line of each test case contains a single integer n (2≤n≤2000)? — the number of other council members.


The second line of each test case contains n integers a1, a2, ..., an

?(1≤ai≤2?105)? — the heights of each of the other members in millimeters.


It is guaranteed that the sum of n over all test cases does not exceed 2000.


Output

For each test case, output on one line n integers representing the heights of the other members in the order, which gives the largest number of photogenic consecutive pairs. If there are multiple such orders, output any of them.

------------------------------------------------------------

佐伯沙耶香是學(xué)生會(huì)成員,學(xué)生會(huì)共有n名成員(不包括沙耶香)。 第i個(gè)構(gòu)件的高度為ai 毫米。


學(xué)年結(jié)束了,沙耶香想給學(xué)生會(huì)的所有其他成員拍一張照片。 作為一個(gè)努力工作、追求完美的女孩,她希望將所有成員排成一排,使上鏡的連續(xù)對(duì)數(shù)盡可能多。


如果一條線上的兩個(gè)連續(xù)成員 u 和 v 的平均高度是整數(shù),即 au+AV2 是整數(shù),則認(rèn)為它們是上鏡的。

幫助沙耶香安排其他成員,使上鏡的連續(xù)配對(duì)數(shù)量最大化。

輸入

第一行包含一個(gè)整數(shù) t (1≤t≤500) — 測(cè)試用例的數(shù)量。


每個(gè)測(cè)試用例的第一行包含一個(gè)整數(shù)n(2≤n≤2000)——其他理事會(huì)成員的數(shù)量。


每個(gè)測(cè)試用例的第二行包含n個(gè)整數(shù)a1, a2, ..., an

? (1≤ai≤2?105) — 其他每個(gè)構(gòu)件的高度(以毫米為單位)。


保證所有測(cè)試用例的n總和不超過(guò)2000。


輸出

對(duì)于每個(gè)測(cè)試用例,在一行上輸出 n 個(gè)整數(shù),表示順序中其他成員的高度,這給出了上鏡連續(xù)對(duì)的最大數(shù)量。 如果有多個(gè)這樣的訂單,則輸出其中任何一個(gè)。

-----------------------------

先把奇數(shù)的元素排完,然后排偶數(shù)的元素即可;

下面是代碼:


CF 1509A - Average Height的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
公安县| 精河县| 云浮市| 同仁县| 宝鸡市| 肥西县| 公主岭市| 肃南| 庆元县| 陕西省| 和平县| 汾西县| 镇坪县| 开原市| 湘潭县| 永昌县| 林西县| 信丰县| 江北区| 建水县| 巴林右旗| 肥城市| 呈贡县| 民和| 普陀区| 将乐县| 南阳市| 三亚市| 旺苍县| 长武县| 商洛市| 富源县| 临洮县| 广宁县| 德清县| 称多县| 沾化县| 塘沽区| 南乐县| 工布江达县| 波密县|