2020 11th java group B first match of the blue bridge cup provincial match

Here is the topic column of the Blue Bridge Cup over the years. It will be updated and will release the real questions and answers from previous years. Welcome friends to pay attention to me. Your likes and attention are the best motivation for me! ! !
Update one real question every day, so stay tuned

Lanqiao Cup Past Papers and Detailed Answers


Question 1: Decryption (5 points)

Title description
Xiao Ming designed a method of article encryption: for each letter c, it becomes some other character Tc. The following table shows the rules for character conversion:
Insert picture description here
for example, the string YeRi can be encrypted to obtain the string EaFn.
Xiao Ming has a random string, encrypted
EaFnjISplhFviDhwFbEjRjfIBBkRyY
(consisting of 30 uppercase and lowercase English letters, excluding line breaks). What is the original string?
(If you copy more strings and tables to a text file, make sure to check the contents of the copied
if there is consistent with the document in a file directory questions str.txt, the first acts of the above character
string, behind the line 52 The contents in the form are listed in order.)
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is a
string containing only 30 uppercase and lowercase English letters. Only fill in this string when submitting the answer, and fill in the
extra content will not be scored.
Topic analysis
topic codes



Question 2: Anniversary (5 points)

Title Description
July 1, 2020 is the 99th anniversary of the founding of the Communist Party of China.
The Communist Party of China was established on July 23, 1921.
How many minutes are included from 12:00 noon on July 23, 1921 to 12:00 noon on July 1, 2020?
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an
integer. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.
Topic analysis
topic codes



The third question: Combined test (10 points)

Title description The
new crown epidemic is caused by the new crown virus and has spread in country A recently. In order to control the epidemic as soon as possible, country A is
preparing to give a large number of people a nucleic acid test for the virus.
However, the test kit is in short supply.
In order to solve this difficulty, scientists thought of a way: combined testing. About to put the specimens collected from multiple people (k) into the same kit for testing. If the result is negative, it means that all k persons are negative, and the test of k persons has been completed with one kit. If the result is positive, it means that at least one person is positive, and it is necessary to retest all the samples of these k persons independently (in theory, if k − 1 persons are negative before the test, it can be inferred that the kth person is positive, but This inference will not be used in actual operation, but k individuals will be tested independently), plus the initial combined test, a total of k + 1 kits have been used to complete the test of k individuals. Country A estimates that the infection rate of the tested population is about 1%, which is evenly distributed. How much can I save the most kits?
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer, and fill in the extra content will not be scored.
Topic analysis
topic codes



Fourth question: Assign masks (10 points)

The title describes that the
mayor of a city has obtained several batches of masks. The number of masks in each batch is as follows: (If you copy the following text into a text file, please be sure to check whether the copied content is consistent with the document. There are A file mask.txt, the content is the same as the text below)
9090400
8499400
5926800
8547000
4958200
4422600
5751200
4175600
6309600
5865200
6604400
4635000
10663400
8087200
4554000
Now the mayor wants to allocate masks to 2 hospitals in the city. Due to logistics restrictions, each batch of masks can only be allocated to one of the hospitals. The mayor hopes that the difference between the total number of masks obtained by the two hospitals is as small as possible. Could you please calculate the smallest difference?
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.
Topic analysis
topic codes



Question 5: The greatest common divisor of the Fibonacci sequence (15 points)

Title description
Insert picture description here

Topic analysis
topic codes



Question 6: Classification and counting (15 points)

Title description
Enter a string, please output how many uppercase letters, how many lowercase letters, and how many numbers this string contains.
[Input format] The
input line contains a character string.
[Output format]
Output three lines, each line an integer, respectively representing the number of uppercase letters, lowercase letters and numbers.
[Sample input]
1+a=Aab
[Sample output]
1
3
1
[Evaluation use case scale and conventions]
For all evaluation use cases, the string consists of visible characters and the length does not exceed 100.
Topic analysis
topic codes



Question 7: Eight times of summation (20 points)

Title description
Insert picture description here
[input format]
The first line of input contains an integer n.
[Output format]
Output one line, including an integer, representing the answer.
[Sample input]
2
[Sample output]
257
[Sample input]
987654
[Sample output]
43636805
[Evaluation use case scale and conventions]
For 20% of evaluation use cases, 1 ≤ n ≤ 20.
For 60% of the evaluation use cases, 1 ≤ n ≤ 1000.
For all evaluation use cases, 1 ≤ n ≤ 1000000.
Topic analysis
topic codes



Question 8: String encoding (20 points)

Title description
Xiao Ming invented a method to encode a string composed of all capital letters. For each capital letter, Xiao Ming converts it into its sequence number in 26 English letters, namely A → 1, B → 2,… Z → 26. Such a string can be transformed into a sequence of numbers: for example ABCXYZ → 123242526. Now given a converted number sequence, Xiao Ming wants to restore the original string. Of course, there may be multiple qualified strings in this restoration. Xiao Ming hopes to find the
string with the largest lexicographical order .
[Input format]
A sequence of numbers.
[Output format]
A string containing only uppercase letters, representing the answer
[Sample input]
123242526
[Sample output]
LCXYZ
[Evaluation use case scale and conventions]
For 20% of evaluation use cases, the input length should not exceed 20.
For all evaluation cases, the length of the input should not exceed 200,000.
Topic analysis
topic codes



Question 9: BST insertion node problem (25 points)

Title description
Given a binary tree containing N nodes, the node numbers are 1 ∼ N. Among them, node i has weight Wi, and the weights of these nodes just form a sorted binary tree (BST). Now given a node number K, Xiao Ming wants to know how many integers X (that is, X is not equal to any Wi) outside of these N weights, satisfy: add a child node with weight X to the node numbered K , You can still get a BST. For example, in the figure below, the numbers outside the parentheses represent numbers, and the numbers inside the parentheses represent weights. The node weights numbered 1 ∼ 4 are 0, 10, 20, and 30 in order.
Insert picture description here
If K = 1, then the answer is 0. Because node 1 already has left and right child nodes, no more child nodes can be added.
If K = 2, then the answer is infinite. Because any negative number can be used as the left child of 2.
If K = 3, then the answer is 9. Because X = 11, 12, · · ·, 19 can all be used as the left child of 3.
[Input format] The
first line contains 2 integers N and K.
Each of the following N rows contains 2 integers, where the i-th row is the parent node number Pi and the weight Wi of the node numbered i. Note that Pi = 0 means i is the root node. The input guarantee is a BST.
[Output format]
An integer represents the answer. If the answer is infinite, output −1.
[Sample input]
4 3
0 10
1 0
1 20
3 30
[Sample output]
9
[Evaluation use case scale and conventions]
For 60% of the evaluation use cases, 1 ≤ K ≤ N ≤ 100, 0 ≤ Wi ≤ 200, and Wi is different.
For all evaluation use cases, 1 ≤ K ≤ N ≤ 10000, 0 ≤ Wi ≤ 100000000, and Wi is different.
Topic analysis
topic codes



Question 10: Network Analysis (25 points)

Title description
Xiao Ming is doing a network experiment. He set up n computers, called nodes, for sending, receiving and storing data. Initially, all nodes are independent and there is no connection. Xiao Ming can connect two nodes through a network cable, and the two nodes can communicate with each other after the connection. If two nodes are connected by a network cable, they are called adjacent. Xiao Ming sometimes tests the network at that time. He will send a message at a node, and the message will be sent to each neighboring node, and then these nodes will be forwarded to their neighbors until all directly or indirectly neighbors The nodes have all received the information. All sending and receiving nodes will store the information. A message is only stored once. Given the process of Xiaoming's connection and testing, please calculate the size of the information stored in each node.
[Input format]
The first line of input contains two integers n, m, which respectively represent the number of nodes and the number of operations. The nodes are numbered from 1 to n. In the next m lines, three integers in each line represent an operation. If the operation is 1 ab, it means that node a and node b are connected by a network cable. When a = b, it means that a self-loop is connected, which has no substantial impact on the network. If the operation is 2 pt, it means that a message of size t is sent on node p.
[Output format]
Output a line, containing n integers, separated by a space between adjacent integers, indicating in turn the size of the information stored on node 1 to node n after the above operations are performed.
[Sample input]
4 8
1 1 2
2 1 10
2 3 5
1 4 1
2 2 2
1 1 2
1 2 4
2 2 1
[Sample output]
13 13 5 3
[Evaluation use case scale and conventions]
For 30% of the evaluation cases, 1 ≤ n ≤ 20 and 1 ≤ m ≤ 100.
For 50% of the evaluation cases, 1 ≤ n ≤ 100 and 1 ≤ m ≤ 1000.
For 70% of the evaluation use cases, 1 ≤ n ≤ 1000 and 1 ≤ m ≤ 10000.
For all evaluation cases, 1 ≤ n ≤ 10000, 1 ≤ m ≤ 100000, and 1 ≤ t ≤ 100.
Topic analysis
topic codes



Guess you like

Origin blog.csdn.net/kiwi_berrys/article/details/111600074