469 - 101學年下學期第四次程式檢定 Scoreboard

Time

2013/06/26 19:15:00 2013/06/26 22:15:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
9360 Word Frequency simplified
9364 Find max in 3n+1 series
9368 Last Man Standing
9372 8 Queens
9376 sparse high-dim points

9360 - Word Frequency simplified   

Description

Given an article, find the number of appearance for queried strings.

Input

The input includes multiple test cases. In each test case, the first line contains two integers, N and M (1 <= N <= 10, 1 <= M <= 100). N indicates the number of lines in the article, and M indicates the number of strings needs to search. The next N lines are for the article, and the length of each line <= 1000. The followed M lines contains M queries, one per line, the length of each query is less than or equal to 50. The input alphabet is (a-z, A-Z) and digit (0-9).

case 1: 1 <= line length <= 100, 1 <= query length <= 20
case 2: 1 <= line length <= 500, 1 <= query length <= 20

case 3: 1 <= line length <= 1000, 1 <= query length <= 50

case 4: 0 <= line length <= 1000, 1 <= query length <= 50

Output

For each string, output the string and the number of appearance in the article, separate by ‘:’. Uppercase and lowercase are treated as the same alphabet.
Print a blank line after the output of each test case.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9364 - Find max in 3n+1 series   

Description

  Consider the following algorithm:

  1. Input n
  2. Set M to be n
  3. If n is equal to 1, then STOP
    Else Set 
  4. M = Max(M , n)
  5. GOTO Step 3.

Given one integer n. Please output the M after processing the algorithm.

Input

The input includes multiple test cases. In each test case, the first line contains one integer n. Guarantee the algorithm won’t go into infinite steps when n is between 1 and 106.

1<= n <= 106

 

For Case1 and Case2, the value during operation will not exceed 10^7.

For Case3 and Case4, the value during operation will not exceed 10^11.


For Case1, the number of test case <= 5000

For Case2, the number of test case <= 50000

For Case3, the number of test case <= 500000

For Case4, the number of testcase <= 1600000

Output

 For each testcase, output one line contains one integer M.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9368 - Last Man Standing   

Description

There are n people standing in a circle waiting to be executed. Starting from the first man, k - 1 people are skipped and the k-th man is executed. Then again, k - 1 people are skipped and the k-th man is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last man remains.

You are given number of people standing in the circle, and number k. You must find the number of last man, who standing in the circle.

Input

The first line contains integer T (0 < T <= 100), it is the number of tests. On each of next T lines there are 2 integers n and k ( 0 < k <= 109).
Case 1: 0 < n <= 102
Case 2: 0 < n <= 103
Case 3: 0 < n <= 104
Case 4: 0 < n <= 105

Output

For each test case out line formatter like this: "Case i: a". Where "i" is a test number, and "a" is the last man standing in the circle (see examples).

Sample Input  Download

Sample Output  Download

Tags




Discuss




9372 - 8 Queens   

Description

Each chessboard has numbers in the range 1 to 99 written on each square and is supplied with 8 chess queens. The task is to place the 8 queens on the chess board in such a way that no queen threatens another one, and so that the sum of the numbers on the squares selected is the maximum . (For those unfamiliar with the rules of chess, this implies that each row and column of the board contains exactly one queen, and each diagonal contains no more than one queen.)

Write a program that will read in the number and details of the chessboards and determine the highest scores possible for each board under these conditions.

 

Input

 Input will consist of K (the number of boards), on a line by itself, followed by K sets of 64 numbers, each set consisting of eight lines of eight numbers. Each number will be a non-negative integer less than 100. Each case is separated by a blank line. There will never be more than 20 boards.

Testcase 1: K<=5 

Testcase 2: K<=10 

Testcase 3: K<=15 

Testcase 4: K<=20

Output

 The outputs of all test cases should be printed in order. For each test case a line, print the highest score right justified in field 5 characters wide.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9376 - sparse high-dim points   

Description

Input will give you a lot of “multi dimension” points, and your mission is to find the minimum distance of all the possible pairs.
The point will give you as follows:
If a 5-dimension point like (1,0,0,3,2), I will give the (index,value) pair in a single line such as (1,1);(4,3);(5,2)


And you can assume that the dimension of each test case is same, because you can fill zero as you want. This means that (1,0,0,3,2) may become 7-dimension such as (1,0,0,3,2,0,0)


And the distance means the Manhattan distance.
P1(p11,p12,p13,p14)
P2(p21,p22,p23,p24)
The distance of P1 and P2 is abs(p11-p21)+abs(p12-p22)+abs(p13-p23)+abs(p14-p24)

abs means the absolute value.

Input

The input includes multiple test cases. In each test case, there are many lines, each line represent a point in the format: (index1,value1);(index2,value2);…(indexM,valueM)
After all the points, ther is a single line “END” represent the ending of this test case.
See the sample input clearly.


The number of points : N
The range of index : idx
The number of pair in a single line I will give you : D
The value of the point : val

case 1: 2<=N<=10, 1<= idx <=5, 1<=D<=5, 0<=val<=100
case 2: 2<=N<=50, 1<= idx <=50, 1<=D<=50, 0<=val<=10^4
case 3: 2<=N<=50, 1<= idx <=10^4, 1<=D<=300, 0<=val<=10^6
case 4: 2<=N<=100, 1<= idx <=10^6, 1<=D<=10^3, 0<=val<=10^8

For example, in case 3, there may be a test case that has 50 points, and each point in the format:
(index1,value1);(index2,value2);…(indexM,valueM)
Then 1<=index1,index2,…indexM<=10^4,
And 0<=value1,value2,…valueM<=10^6
And D = 300 means each point I will give you at most 300 pairs, that is 1<=M<=300.

Output

For each test case, output the minimum distance of all the possible pairs.

Sample Input  Download

Sample Output  Download

Tags




Discuss