| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12439 | Little Brick's Functions |
|
| 12974 | Let's Puzzle |
|
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
Description
Puzzle is a very annoying to find the next piece to fill in.
As a CS student, you decides to help peoples to solve this problem by your programimg skill.
There’s a n × m incomplete puzzle board.
The empty fields are marked as o while the filled ones are #.
Let’s define space = colletion of the connected empty field.
That is, there’re one space(3x3) on the Board 1, and two spaces(1x3) on the Board 2.
// Board 1, Board 2
##### #####
#ooo# #ooo#
#ooo# #####
#ooo# #ooo#
##### #####
Now, there’re T pieces of puzzle to check whether each of them is able to be put into the space on the board or not.
Because the orientation of piece is important in painting puzzle, it’s no need to check the rotated piece can be put into board or not.
The shapes of piece is also described by o, #.
The following examples representing the piece with rectangle, cross, mountant shape.
### o#o oo#oo
### ### #o#o#
o#o #####
Your task is to answer these pieces can be put in to the given board or not.
Type of shape
1. rectangle: the shape is a filled rectangle.
# ## ## ####
## ####
## ####
2. symmetric: the shape is the same after any rotation.
### oo#o oo#oo
#o# ###o oo#oo
### o### #####
o#oo oo#oo
oo#oo
3. irregular: the shape has no rule.
##o #### oo#oo
#oo #o#o #o#o#
### #ooo #####
Hint for Testcases
| Testcases | Number of space | Shape of space | Shape of pieces |
| 1 | 1 | Sample | Sample |
| 2 | 1 | rectangle | rectangle (1x1) |
| 3 | 1 | rectangle | rectangle |
| 4 | 1 | symmetric | symmetric |
| 5 | no restriction | irregular | irregular |
Input
There’re two integers n, m on the first line.
The following n lines contains m charactors, representing the n×m incompleted board.
There’s an integer T on the next line, denoting the number of pieces.
And then are T pieces of puzzle.
For each piece, there’re two integers ri,ci, denoting the size of pieces.
The next ri lines with ci charactors are the shape of ith piece.
It’s guaranteed that:
- 1 ≤ n, m ≤ 50
- 1 ≤ T ≤ 100
- 1 ≤ ri, ci ≤ 4
- All pieces only have one connected component.
- There’s no redudant rows or columns in pieces.
In the other word, there’s at least one#for the first row, last row, first column, and last columns.
That is, the following pieces will not happen in the Input
2 3 // 2 connected component
#o#
#o#
#o#
2 4 // 4 connected component
#o#o
o#o#
3 3 // 3-rd row is redudant
###
o#o
ooo
2 2 // 1-st row, 1-st column are redudant
oo
o#
Output
There’re T lines for output.
Print “Yes” on the ith line if the ith piece can be put in to board.
Otherwise, “No” on the ith line.
Remember ‘\n’ on the end of each lines.