| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10768 | wave |
|
| 10769 | Two-dimensional array rotation |
|
| 10770 | Coordinate Format |
|
| 10772 | The number of occurrences |
|
| 10773 | Fish Farmer |
|
| 10774 | Progression |
|
Description
A character wave consistss of lines of characters, which has a parameter, length L. The number of characters in the first line is 1, and is increased by one in the every following lines. After the number of character reaches L, it starts to descrease until the number of characters become 1 again. For example, the following is a character wave of length 3.
#
##
###
##
#
Input
Output
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given an NxN two-dimensional array M, you are asked to rotate M clockwise by 45 degrees and print out the content of M.
Consider the following 2D array:

After being rotated 45 degrees clockwise, it will become:

In this case, you should print:
1
4 2
7 5 3
8 6
9
Input
The first line has N (2<=N<=20), which means the size of the 2D array. The total number of elements in the 2D array is thus N x N.
For the next N lines, each contains N integers, specifying the elements of the 2D array. All of the integers in the same line are separated by a space.
Output
Print out all elements of the rotated 2D array row-by-row.
All of the integers in the same line are separated by a space, and there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given an 2-dimensional array, please find the non-zero values and print out (row, col, value) tuples.
Input
First line indicates size of the 2-dimensional array is M(0<M<=100) rows by N(0<N<=100) columns.
The following M lines are rows of the 2-dimensional array, and each line contains N integers.
Output
(row, col, value) tuples of non-zero elements, one tuple each line. Tuples are sorted by row major order. Index number starts from 0.
All of the integers at the same line are separated by a space, and there is a ‘\n’ at the end of each line.

Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a string A and n strings B1, B2, B3, …, Bn, count the number of occurrences of string A in each of B1, B2, B3, … , and print the maximum number of occurrences. All of the strings contain only digits.
For example, if A is “50” , n = 3, and the n strings are
“5005”
“055050”
“55000”
then your answer should be 2 because A appears in “5005” one time, in “055050” two times, and in “55000” one time. So the maximum number of occurrences is 2.
Note that if A is “99” and B1 is “9999”, the number of occurrences of A in B1 is counted as 3.
You may assume string B1 is always longer than string A.
Input
The first line of the input is the string A (0<length of A<=4). The second line is n (1<n<10) .
For the next n lines, each line contains a string Bi (length of A < length of Bi <9) and a ‘\n’ at the end of the line.
Output
The maximum number of occurrences of A appears in B1, B2, …, Bn. Note that you DO NOT need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Adam is a fish farmer whose job is to manage two fishponds A and B. At the beginning of the first year, fishponds A and B contains N and M fish, respectively. The number of fish in each pond increases by 8% every year. At the beginning of each of the following K years, Adam moves some amount of fish from one fishpond to the other. You are asked to help calculate the amount of fish in fishponds A and B after K years.
Note: When you calculate the amount of fish by multiplying the increasing rate, you should round the result down to the nearest integer; For example,1.7→1. (無條件捨去成整數).
Consider the following example:
- In the beginning of year 1:
- fishpond A contains 500 fish
- fishpond B contains 300 fish.
- In the beginning of year 2:
- fishpond A contains (500*1.08) -25=540-25=515 fish
- fishpond B contains (300*1.08) +25=324+25=349 fish
- In the beginning of year 3:
- fishpond A contains (515*1.08)+150=556+150= 706 fish
- fishpond B contains (349*1.08) -150=376-150=226 fish
- In the beginning of year 4:
- fishpond A contains (706*1.08)+176=762+176= 938 fish
- fishpond B contains (226*1.08) -176=244-176=68 fish
Input
The input contains several lines. The first line contains two positive integers N and M, which represents the number of fish in fishponds A and B at the beginning of the first year, respectively.
The second line contains a positive integer K, which represents the number of years you should consider.
Each of the remaining K lines contains two elements, which are separated by a blank, describing the fish movement in each year, starting from the 2nd year:
- The first element indicates the instruction.
- ‘A’: move fish from A to B
- ‘B’: move fish from B to A
- The second element indicates the number of fish that are moved. (0 < the number of fish < 1000)
Output
The amounts of fish in fishponds A and B in the beginning of year K+1, respectively, which are separated by a blank. Note that you need to print a '\n' at the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The input contains a series of numbers that is either an arithmetic progression (等差數列) or a geometric progression (等比數列). You task is to distinguish which progression it is from the first four numbers and calculate the fifth number, and also print the common difference (公差) or the common ratio (公比).
For example, if the input is 1 3 5 7, then you know this is an arithmetic progression. The next number is 9 and the common difference is 2. So the output should be 9 2 .
There are NO progression like 1 1 1 1 or 2 2 2 2 which are both an arithmetic progression and a geometric progression.
Note that input and the output are all integers.
Input
Four integers
Output
The next number of the progression and the corresponding common difference or common ratio. The two numbers should be separated by a blank.
You DO NOT need to print ‘\n’ at the end of the output.