## BestCoder Round #54(Div.2) (4/4) (Div.1) (3/4)

maksyuki 发表于 比赛 分类，标签:

# A problem of sorting

Problem Description

There are many people's name and birth in a list.Your task is to print the name from young to old.(There is no pair of two has the same age.)

Input

First line contains a single integer T≤100 which denotes the number of test cases.

For each test case, there is an positive integer n(1≤n≤100) which denotes the number of people,and next n lines,each line has a name and a birth's year(1900-2015) separated by one space.

The length of name is positive and not larger than 100.Notice name only contain letter(s),digit(s) and space(s).

Output

For each case, output n lines.

Sample Input

2

1

FancyCoder 1996

2

FancyCoder 1996

xyz111 1997

Sample Output

FancyCoder

xyz111

FancyCoder

Source

BestCoder Round #54 (div.2)

# B The Factor

Problem Description

There is a sequence of n positive integers. Fancycoder is addicted to learn their product, but this product may be extremely huge! However, it is lucky that FancyCoder only needs to find out one factor of this huge product: the smallest factor that contains more than 2 factors（including itself; i.e. 4 has 3 factors so that it is a qualified factor）. You need to find it out and print it. As we know, there may be none of such factors; in this occasion, please print -1 instead.

Input

The first line contains one integer T (1≤T≤15), which represents the number of testcases.

For each testcase, there are two lines:

1. The first line contains one integer denoting the value of n (1≤n≤100).

2. The second line contains n integers a1,…,an (1≤a1,…,an≤2×109), which denote these n positive integers.

Output

Print T answers in T lines.

Sample Input

2

3

1 2 3

5

6 6 6 6 6

Sample Output

6

4

Source

BestCoder Round #54 (div.2)

# C Geometric Progression

Problem Description

Determine whether a sequence is a Geometric progression or not.

In mathematics, a **geometric progression**, also known as a **geometric sequence**, is a sequence of numbers where each term after the first is found by multiplying the previous one by a fixed, non-zero number called the common ratio. For example, the sequence 2, 6, 18, 54, ... is a geometric progression with common ratio 3. Similarly 10, 5, 2.5, 1.25, ... is a geometric sequence with common ratio 1/2.

Examples of a geometric sequence are powers rk of a fixed number r, such as 2k and 3k. The general form of a geometric sequence is

a, ar, ar2, ar3, ar4, …

where r ≠ 0 is the common ratio and a is a scale factor, equal to the sequence's start value.

Input

First line contains a single integer T(T≤20) which denotes the number of test cases.

For each test case, there is an positive integer n(1≤n≤100) which denotes the length of sequence,and next line has n nonnegative numbers Ai which allow leading zero.The digit's length of Ai no larger than 100.

Output

For each case, output "Yes" or "No".

Sample Input

4

1

0

3

1  1  1

3

1 4 2

5

16 8 4 2 1

Sample Output

Yes

Yes

No

Yes

Source

BestCoder Round #54 (div.2)

# D Reflect

Problem Description

We send a light from one point on a mirror material circle,it reflects N times and return the original point firstly.Your task is calcuate the number of schemes.

Input

First line contains a single integer T(T≤10) which denotes the number of test cases.

For each test case, there is an positive integer N(N≤106).

Output

For each case, output the answer.

Sample Input

14

Sample Output

4

Source

BestCoder Round #54 (div.2)