P8678 [Lanqiao Cup 2019 NOI Qualifier A] Fill-in-the-Blank Problems
Description
## A Sum of Squares
### Problem Description
Xiaoming is very interested in numbers whose digits contain `2`, `0`, `1`, or `9`. From $1$ to $40$, such numbers include $1$, $2$, $9$, $10$ to $32$, $39$, and $40$, totaling $28$ numbers. Their sum is $574$, and the sum of squares is $14362$. Note that the sum of squares means squaring each number and then summing them up.
In $1$ to $2019$, what is the sum of squares of all such numbers?
### Answer Submission
This is a fill-in-the-blank question. You only need to compute the result and submit it. The result is an integer. When submitting, only fill in this integer; any extra content will result in no score.
Hint: If you write a program to compute it and find that the result is negative, please carefully check your program. Do not doubt the programming software used in the contest.
## B Sequence Evaluation
### Problem Description
Given the sequence $1,1,1,3,5,9,17,\cdots$, starting from the $4$-th term, each term equals the sum of the previous $3$ terms. Find the last $4$ digits of the $20190324$-th term.
### Answer Submission
This is a fill-in-the-blank question. You only need to compute the result and submit it. The result is a $4$-digit integer (hint: the thousands digit is not $0$). When submitting, only fill in this integer; any extra content will result in no score.
## C Maximum Rainfall
### Problem Description
Because the Land of Sand has been dry for many years, the mage Xiaoming plans to cast a mysterious spell to make it rain.
This spell requires the $49$ spell cards in his hand, each labeled with a number from $1$ to $49$. The spell lasts for $7$ weeks. Every day, Xiaoming must use one spell card, and no card may be used more than once.
Each week, the energy produced by the spell is the median of the numbers on the $7$ spell cards used that week. After $7$ weeks, the rainmaking will succeed, and the rainfall is the median of the energies of the $7$ weeks.
Since it has been dry for too long, Xiaoming wants the rainfall to be as large as possible. What is the maximum value?
### Answer Submission
This is a fill-in-the-blank question. You only need to compute the result and submit it. The result is an integer. When submitting, only fill in this integer; any extra content will result in no score.
## D Maze
### Problem Description
The following figure gives a top view of a maze. Cells marked as $1$ are obstacles, and cells marked as $0$ are passable.
```
010000
000100
001001
110000
```
The entrance of the maze is the top-left corner, and the exit is the bottom-right corner. In the maze, you can move from one cell to one of its four directions: up, down, left, or right.
For the maze above, starting from the entrance, you can pass through the maze by following `DRRURRDDDR`, for a total of $10$ steps. Here `D`, `U`, `L`, `R` represent moving down, up, left, and right, respectively.
For the more complex maze below ($30$ rows and $50$ columns), please find a way to pass through the maze using the minimum number of steps. Among all shortest paths, output the one with the smallest lexicographical order. Note that in lexicographical order, $\mathrm{D}
Input Format
Input one uppercase letter indicating which problem it is.
Output Format
According to the input problem label, output the corresponding answer.
Explanation/Hint
Answer template for reference.
```cpp
#include
using namespace std;
int main() {
string ans [] = {
"The answer of task A", // Replace inside the double quotes with the answer to task A
"The answer of task B", // Replace inside the double quotes with the answer to task B
"The answer of task C", // Replace inside the double quotes with the answer to task C
"The answer of task D", // Replace inside the double quotes with the answer to task D
"The answer of task E", // Replace inside the double quotes with the answer to task E
};
char T;
cin >> T;
cout