2415 - I2P(I)2021_Yang_hw6 Scoreboard

Time

2021/11/02 20:30:00 2021/11/09 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11710 GCD(recursive)
12941 The Game of Life
13304 Count the wood

11710 - GCD(recursive)   

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.

Hint:
To compute gcd(48,18), divide 48 by 18 to get a quotient of 2 and a remainder of 12. Then divide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by 6 to get a remainder of 0, which means that 6 is the gcd

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




12941 - The Game of Life   

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:

  1. Any live cell with two or three live neighbours survives.
  2. Any dead cell with exactly three live neighbours becomes a live cell.
  3. 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




13304 - Count the wood   

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 ≤ NM ≤ 1000).

The next 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. 

 

Sample Input  Download

Sample Output  Download

Tags




Discuss