第一题
It is really amazing that the great historian Dr.K has recently found that about 10 Million years ago, in the area where is now called China, lived an ancient people. They may be considered as the first intelligent creature existed on the earth.
As Dr.K's investigation advance, he found unbelievably that they even developed some so-called mathematics during their evolvement. Dr.K spent his half life to understand this ancient people's counting system. Finally he got to know that:
1、They use only 7 digits to represent numbers, and numbers are as follow:
| -> 1
|| -> 2
||| -> 3
|||| -> 4
||||| -> 5
|||||| -> 6
||||||| -> 7
It is a pity that they have not developed "0" before these people disappeared.
2、If a number is greater than 7, they use digit place just as we do today. Between each two digit places, there is a ",".
eg:
|||||,|| -> 42 (5x8+2)
|||,||,|||| -> 212 (3*64+2*8+4)
In order to further his study, Dr.K wants to know what the sequences found from stones mean in today's counting system. He turns to you for help, and smart as you are, you should help this great historian,should not you?
Input
The first line of standard input contains an integer N, the number of test cases. N lines followed.
In each line a sequence is given, it is guaranteed that the length of the sequence will not exceed 1024 characters and the outcome number will not be greater than 1000000.
Output
For each case you are to output a line giving the number in today's decimal counting system.
Sample Input
3
|||||,||
|||,||,||||
||,|,|,|,||||
Sample Output
42
212
8780
第二题
Given a string of letters(A-Z),your task is to arrange them in alphabetic order.
Following is an example:
A string "BAC" contains 3 letters B,A and C,you should output
ABC
ACB
BAC
BCA
CAB
CBA
In the output file.
A string may contain several letters same,for example "BBC" you should output like this:
BBC
BCB
CBB
Input
The first line of input contains a single integer t, the number of test cases,followed by the input data for each test data.Each test case is a string of n(1<=n<=26) letters.
Output
You should output Case K: in the first line and the sequences of arrangement in the following lines of each case.
Sample Input
2
BAC
BBC
Sample Output
Case 1:
ABC
ACB
BAC
BCA
CAB
CBA
Case 2:
BBC
BCB
CBB
第三题
There are N(N<=50) good friends. One day they want to play together in one of their home. There may be road between two houses. We can describe a house as an vertex and a road as a edge between two vertexes. Every one goes at the same speed. At the very beginning, everyone stays at their own home. Now they want to play together as early as possible, that's to say they expect the latest one reach destination as early as possible. But they don't know whose house to get together in, can you help them?
Input
Input contains multiple cases. The first line is a integer T representing the number of test cases.The first line of each case contains two integers N and M. Then M lines follow. Each of the M lines contains three integers a, b, and c,which means that vertex a and b exist a edge whose distance is c.
Ouput
For each test case find which vertex to get together. If there is no such vertex print a single line "No solution." instead.
Sample Input
3
3 2
0 1 10
1 2 10
4 3
0 1 10
1 2 10
2 3 10
4 2
0 1 5
2 3 7
Sample Output
1
1
No solution.
第四题
There are n tasks {1,2,3...,n} waiting in line to be operated on the computer. Task i needs Ti CPU time to be finished. Your task is to find a way to maximize the number of tasks can be finished in time T. If there are more than one way containing maximum tasks, then maximize the CPU time used in time T.
Input
The first line contains a integer t (1<=t<=100), the number of test cases. The first line of each case contains integer n and T, representing n tasks and in time T the maximum tasks can be finished and the maximum CPU can be used. The second line of each case contains the time {T1,T2,T3...Tn} each task needs to be finished. All numbers are integer in the input file.
Output
For each test case, output a line with the maximum number of tasks can be finished and the maximum of CPU time can be used in time T. One test case per line and separated by one whitespace.
Sample input
1
7 47
30 78 33 76 66 8 78
Sample Onput
2 41
第五题
There are two sequences A and B with N (1<=N<=10000) elements each. All of the elements are positive integers. Given C=A*B, where '*' representing Cartesian product, c = a*b, where c belonging to C, a belonging to A and b belonging to B. Your job is to find the K'th largest element in C, where K begins with 1.
Input
Input file contains multiple test cases. The first line is the number of test cases. There are three lines in each test case. The first line of each case contains two integers N and K, then the second line represents elements in A and the following line represents elements in B. All integers are positive and no more than 10000.
Output
For each case output the K'th largest number.
Sample Input
2
2 1
3 4
5 6
2 3
2 1
4 8
Sample Output
24
8