985 - 104學年下學期第五次程式檢定 Scoreboard

Time

2016/07/22 13:00:00 2016/07/22 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10953 Simply Fractions
11091 Suffix Prefix
11092 Mouse Maze
11093 Set Intersection
11094 Binary Addition

10953 - Simply Fractions   

Description

Given several fractions, compute their sum and express the answer in the simplest fraction form.

 

Input

There are many test cases in one subtask.


The first line of each test case contains an integer t, which indicates the number of fractions in the input. Each of the following t lines contains two integers a and b, which represent the numerator and the denominator of a fraction.

subtask 1 : t=2. 1<=a,b<=10.
subtask 2 : t<=5. 1<=a,b<=10.
subtask 3 : t<=5. 1<=a,b<=50.
subtask 4 : t<=10. 1<=a,b<=100.

 

Output

Each test case outputs one line.


The output is the sum reduced to the simplest fraction form. You need to print a '/' between the numerator and the denominator.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




11091 - Suffix Prefix   

Description

The words "waterproof" and "proofreading" have a common part "proof", which is the prefix of "proofreading" and the suffix of "waterproof". Given all possible pairs extracted from a list of words, your task is to find the length of the common suffix-prefix of a pair that is the longest one.

For example, if the list consists of "proofreading", "waterproof", and "ingredient", then the answer will be 5, since the common suffix-prefix for the pair of "waterproof" and "proofreading" contains 5 letters and is the longest, in comparison with the common suffix-prefix for the pair of "proofreading" and "ingredient", which is "ing" and has only 3 letters.

 

Input

There are multiple test cases (less than 500). Each case starts with an integer N indicating the number of words. The next N strings are the list of the words for this test case. Each word has at most M letters, all in lower-case.

case 1: 2 <= N <= 10, M=15
case 2: 2 <= N <= 20, M=15
case 3: 2 <= N <= 20, M=30
case 4: 2 <= N <= 30, M=30

 

Output

There should be one line after each test case. Each line shows an integer that represents the longest length of the common part for the best choice of word pair.

Sample Input  Download

Sample Output  Download

Tags

udhsfuihurnjhsdfiuhh s sv verificationWorkflow youNeed



Discuss




11092 - Mouse Maze   

Description

Write a program that simulates a mouse in a maze. The program must count the steps taken by the mouse from the starting point to the final point.

The maze type is shown in following figure:

S$###
$$#$$
$$$##
##$$F

it consists of S (starting point), #(walls), $(road) and F (final point).

In above case, it needs 7 steps from S to F as following figure,

S$###
$$#$$
$$$##
##$$F

and the mouse can move in the four directions: up, down, left, right. There may be more than one way to reach final point, the program only need to print the least steps.

If there is no way from S to F, then print -1.

Input

The first line has an integer N(1<=N<=1000), which means the number of test cases.

For each case, the first line has two integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of rows and columns of the maze, respectively. The total number of elements in the maze is thus R x C.

The following R lines, each containing C characters, specify the elements of the maze.

Output

Print out the least steps for each case, and there is a new line character at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11093 - Set Intersection   

Description

Given two sets of numbers, output their intersection set.

Input

There are multiple test cases.

Each case contains four lines.

The first line begins with an integer N.

The second line contains N integers, representing the numbers in the first set.

The third line has one integer M, and the fourth line contains M integers, represent the numbers in the second set.

All the numbers are 32 bit signed integersAll the numbers in the set are listed in ascending order and are unique.

The input is terminated if N = 0.

For Case 1, 1 <= N, M <= 10^3
For Case 2, 1 <= N, M <= 10^4
For Case 3, 1 <= N, M <= 10^5
For Case 4, 1 <= N, M <= 10^6

Output

For each test case, print the intersection of the two sets. Output each number in ascending order and separate them by a space. If the intersection of the two sets is an empty set, print "empty" (without quotes).

Sample Input  Download

Sample Output  Download

Tags




Discuss




11094 - Binary Addition   

Description

Please compute the sum of two given n-bit binary numbers.

Input

The first line of the input file contains a positive integer t indicating the number of test cases. The first line of each test case is a positive integer n denoting the length of bits. The second and third lines are the two n-bit binary numbers. The first bit of each binary number is always 0, which guarantees that the sum of the two binary numbers can still be expressed as an n-bit binary number.

Case1 : t<=100, n<=100
Case2 : t<=200, n<=1000
Case3 : t<=300, n<=5000
Case4 : t<=400, n<=10000

Output

For each test case, your program should print the sum in the same format as the binary numbers given in input.

Sample Input  Download

Sample Output  Download

Tags




Discuss