# | Problem | Pass Rate (passed user / total user) |
---|---|---|
14528 | Loki doing Math |
|
14529 | Bidirectional DomoMaze |
|
14530 | Toad Jumping |
|
Description
Loki need to pursue physics, however he need to undersand basic math first.
In the first lecture, he already messed up with the prefix to infix equation. Can you help him?
Given Math Equation in prefix form, try to figure out the infix equation with the least amount of necessary parenthesis
e.g. given prefix form * - 20 30 50
the infix form will be (20-30)*50
((20-30)*50)
is wrong since there is an unnecessary parenthesis
The opreator only consist of +
, -
, *
, and /
Same as homework, try to use getline and use strlen if the length is neccesarry
size_t buf = 0;
while(getline(&equation, &buf, stdin) != -1){
// TODO
}
#include <stdio.h>
int main(){
char buffer[100];
while(fgets(buffer, sizeof(buffer), stdin) != NULL){
printf("Char %s", buffer);
}
return 0;
}
Try to get used to the function above
Input
There will be multiple testcase, each testcase have only 1 line string input
len(string) < 10000
Every number shown in the string are in range [0, 9999]
Testcase 1-2: only operator +
Testcase 3-4: operator +
and -
Testcase 5-6: operator +
, -
, and *
Testcase 7-8: operator +
, -
, *
, and /
Output
For each testcase, print the infix equation, ended by a newline character
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Domo is a brilliant dog. By the way, his grandfather is also a brilliant dog, and he has built a giant maze in the forest years ago, which is called "DomoMaze". However Domo is more brilliant, as he made "Bidirectional DomoMaze"!
One day, Domo loses his ball called Wilson in this maze. He wants to take Willson back, and your task is to find out how many ways Domo can reach the position where Willson is.
This "Bidirectional DomoMaze" can be described as a two-dimensional array. With height (H) and width (W), Domo is at the position (0, 0) in the beginning, and Wilson is at the position (A, B)
Each time Domo moves, he can choose one of three ways below:
- from (i, k) to (i+1, k)
- from (i, k) to (i, k+1)
- from (i, k) to (i+1, k+1)
Also, there is a reverse sign block. If Domo step to certain position (i, k) where there is a reverse block, he will change the movement set. The reverse block will dissapear. The movement set as below:
- from (i, k) to (i+1, k)
- from (i, k) to (i, k-1)
- from (i, k) to (i+1, k-1)
If he step the reverse block for the second time, the movement set will reset to the original one.
Input
The first line contains two integers H (2 ≤ H ≤ 15) and W (2 ≤ W ≤ 15) - the height and the width of DomoMaze
The second line contains two integers A (0 ≤ A ≤ H-1) and B (0 ≤ B ≤ W-1) - The Position of the Ball (guaranteed not (0, 0))
For the next H lines, each line has W numbers either 1 or 0 - 0 for empty, and 1 for the reverse block.
Special Testcases:
- Testcase 1-4: A and B will always at (H-1, W-1), no Reverse Block
- Testcase 5-6: A and B can be anywhere, no Reverse Block
- Testcase 7: A and B can be anywhere, one Reverse Block
- Testcase 8: A and B can be anywhere, two Reverse Block
Output
The output only contains a number and a newline character - the number of ways Domo can reach where Wilson is
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You are transformed into a toad
As a toad, you can jump 1-3 block(s)
Starting from the 1st block, how many way you can reach until the Nth block?
Also, there might be a hole in the block, as toad can't jump into that block
Hint: You might want to use long long to store
Sample IO #1 testcase explanation
[0, 0, 0, 0, 0]
There are 7 ways:
- 1 jump, 1 jump, 1 jump, 1 jump
- 2 jump, 1 jump, 1 jump
- 1 jump, 2 jump, 1 jump,
- 1 jump, 1 jump, 2 jump
- 2 jump, 2 jump
- 3 jump, 1 jump
- 1 jump, 3 jump
Sample IO #3 testcase explanation
[0, 1, 1, 0, 0]
There is only 1 way to solve this:
- 3 jump, 1 jump
Input
There are T testcases
first line of each testcase has integer N
second line of each testcase has N elements, either 0 or 1
0 means default block, 1 means hole
1 <= T <= 100
2 <= N <= 50
The first and last block can't be a hole
Output
The integer consist how many possible ways to do it, with a newline character