2158 - I2P(I)2020_Yang_HW7 Scoreboard

Time

2020/11/03 21:00:00 2020/11/10 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12439 Little Brick's Functions
12910 Let's build a Tetris

12439 - Little Brick's Functions   

Description

One day, Little-Brick(小磚頭) found 3 functions,
GCD, LCM and POWER
GCD(a, b) is to compute the greatest common divisor of a and b,
LCM(a, b) is to compute the least common multiplier of a and b,
POWER(a, b) is to compute ab.

Little-Brick's is not so good as math,
even that he doesn't know how to use these functions,
he doesn't care about it,

he decide to take 4 numbers and substitute them into these functions.

Now, he is asking you to tell him the answer of the result of substitute these 4 numbers into functions in all order,
that is, given you 4 integer A, B, C, D,
you should output the result of GCD(LCM(POWER(A, B), C), D), GCD(POWER(LCM(A, B), C), D), LCM(GCD(POWER(A, B), C), D), LCM(POWER(GCD(A, B), C), D), POWER(GCD(LCM(A, B), C), D), POWER(LCM(GCD(A, B), C), D), each in a single line.

Hint: LCM(a, b) = a * b / GCD(a, b)

You can follow the format of the following suggested code,
or feel free to have your own version.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>

int gcd(int a, int b) {
	// your code here
}

int lcm(int a, int b) {
	// your code here
}

int power(int a, int b) {
	// your code here
}

int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", gcd(lcm(power(a, b), c), d));
	// ... other 5 lines 
	return 0;
}

 

ouo.

Note:

Please solve the problem using recursion rather than loop. Practice recursion :)

Input

Input contain 4 integer A, B, C, D, seperate by spaces.
1<= A, B, C, D <= 100

Output

Output contains 6 lines.

Output he result of GCD(LCM(POWER(A, B), C), D), GCD(POWER(LCM(A, B), C), D), LCM(GCD(POWER(A, B), C), D), LCM(POWER(GCD(A, B), C), D), POWER(GCD(LCM(A, B), C), D), POWER(LCM(GCD(A, B), C), D), each in a single line.

It is guarantee that the result of every call of function will < 231

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




12910 - Let's build a Tetris   

Description

You may have heard of the game Tetris Battle on Facebook,
it's was once popular and you may even have played it before.

You, after Tetris Battle closed down on May 31, 2019,
haven't played a Tetris game for a while.

Since there is no more Tetris Battle to play,
you decide to build one by yourself.

The game field of the tetris has N rows and M columns,
and there are already some piecies that is already placed on the field,
we mark them as character 'x',
and other field that hasn't been occupied by piecies are marked as character '.'.

Now, there is a falling piece, marked as 'o',
and the player want to drop the falling piece directly.

The falling piece will descend until it touch the bottom of the field,
or it land on pieces that were placed before.

If a row is completed, the row will disappear and all rows above will fall one level.

Your mission is to tell after the falling piece landed,
and all completed rows are eliminated,
what will the game field looks like?

ouo.


For sample 1,
the input is:

8 9
..o......
.oo......
..o......
.........
.........
x..xxxxxx
x..xxxxxx
xx.xxxxxx​

so the falling piece will descend 5 levels until it touch the bottom of the game field, and becomes:
.........
.........
.........
.........
.........
x.oxxxxxx
xooxxxxxx
xxoxxxxxx​

and since the last 2 rows are completed, so they disappear and the third row from last falls 2 levels and becomes:
.........
.........
.........
.........
.........
.........
.........
x.xxxxxxx


For sample 2,

..o......     .........     .........
..o......     .........     .........
..o......     .........     .........
..o......     .........     .........
.........     .........     .........
.........  => ......... =>  .........
.........     .........     .........
xx.xxxxxx     xxoxxxxxx     .........
xx.xxx.xx     xxoxxx.xx     .........
x..xxxxxx     x.oxxxxxx     xxxxxx.xx
xx.xxxxxx     xxoxxxxxx     x.xxxxxxx


For sample 3:

.......     .......     .......
...oo..     .......     .......
..oo...     .......     .......
..o....     .......     .......
....... =>  ...oo..  => .......
.x.....     .xoo...     ...xx..
xx.xxxx     xxoxxxx     .xxx...
x.xxxxx     x.xxxxx     x.xxxxx

Input

The first line of the input contains 2 integers, N and M,
represent that the game field has N rows and M columns.

After that, there are N lines, each lines contains M character,
the character '.' represent that the cell is empty, not occipied,
the character 'x' represent that the cell is already placed and has been occupied,
the character 'o' represent that the cell is part of the falling piece.

It is a guaranteed that:
1 <= N, M <= 40,

the input game field will always be valid,
and all 'o' character will be connected.

Note that the shape of 'o' will may not be a normal Tetromino, it can be any shape.

Output

Output contains N lines, each line has M character,

output character '.' if the cell is empty and character 'x' if the cell is occipied.

Sample Input  Download

Sample Output  Download

Tags




Discuss