# | Problem | Pass Rate (passed user / total user) |
---|---|---|
11710 | GCD(recursive) |
|
12941 | The Game of Life |
|
13304 | Count the wood |
|
Description
Given two positive integers a and b, compute the greatest common divisor (GCD) of a and b. The GCD of a and b is the biggest integer that can divide a and b with no reminder.

Input
First line contains a positive integer t (t<=10000), which indicates the number of test cases in the input. In the next t lines, each line contains two positive integers a, b, which are smaller than or equal to 10^6.
Output
For each case, output the GCD of a and b in a line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The Game of Life is devised by the British mathematician John Horton Conway.
This Game consists of a grid of cells, each of which is in one of possible state, live or dead.
For each generation, every cell interacts with its eight neighbors in the following rules:
- Any live cell with two or three live neighbours survives.
- Any dead cell with exactly three live neighbours becomes a live cell.
- All other live cells die in the next generation. Similarly, all other dead cells stay dead.
The following 2 gifs are the examples of the Game of Life: ( Black = live, White = dead )
Given the initial state of n×m grid of cells.
Your task is to find the state of grid of cells after T generations.
Hint:
It's possible to access the invalid index ( arr[-1][0] ) of array when counting the neighbors.
In C, this behavior may not cause any error message.
Notice the boundary cases, and you will get AC in this problem. :)
Input
Three integers n, m, T on the first line.
The following n lines consist m numbers for each lines.
There’re si1, si2, ..., sim on the ith line, representing the initial state of grid of cells.
sij denotes the state of cell at position (i,j), 0,1 mean dead and live respectively.
It’s guaranteed that:
- 1 ≤ n, m, T ≤ 500
- sij ∈ { 0, 1 }
Output
Print the grid of cells after T generations.
Remember ‘\n’ after the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The floor in Winnie the Pooh’s house is made of N row *M column square woods,
When he cleaned the house, he observed that there are two types of wood — 'o' and '#' .
He wants to know the maximum number of consecutive woods with the same type in a row or column of each type respectively.
Input
The first line you are given an integer T, means there will be T tests.(1<=T<=10).
Each test you are given integers N, M (1 ≤ N, M ≤ 1000).
The next N lines contains M characters('o' or '#').
Output
Each test output the maximun number of consecutive 'o' woods, the maximun number of consecutive '#' woods, and a new line.