Real Questions of the 8th Java Group B Blue Bridge Cup Provincial Competition in 2019

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: Team up

Title Description
As a basketball team coach, you need to select one player from position 1 to position 5 from the following list to form the team's starting lineup.
The scores for each player from position 1 to position 5 are shown in the table below. Would you please calculate the maximum possible sum of the scores from the 1st to the 5th of the starting lineup?
Insert picture description here

Topic analysis
topic codes



Question 2: Different substrings

Title description
A non-empty substring of a string refers to a string of consecutive characters with a length of at least 1 in the string. For example, the string aaab has non-empty substrings a, b, aa, ab, aaa, aab, aaab, a total of 7 substrings. Note that when calculating, only count the number of strings that are essentially different.
Excuse me, how many different non-empty substrings are there in the string 0100110001010001?

[Answer Submission]
This is a question that fills in the blanks with the result, 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 3: Evaluation of a sequence

Title description
Given a sequence of 1, 1, 1, 3, 5, 9, 17, …, starting from item 4, each item is the sum of the first three items. Find the last 4 digits of item 20190324.
[Answer Submission]
This is a question that fills in the blanks with the result, you only need to calculate the result and submit it. The result of this question is a 4 digit integer (hint: the thousand digit of the answer is not 0). 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: Decomposition of numbers

Title description
Decompose 2019 into the sum of 3 different positive integers, and require that each positive integer does not contain the numbers 2 and 4. How many different decomposition methods are there?
Note that the order of exchanging 3 integers is considered the same method, for example, 1000+1001+18 and 1001+1000+18 are considered the same.
[Answer Submission]
This is a question that fills in the blanks with the result, 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: Labyrinth

Title description The
following figure shows a plan view of a maze, where the obstacles marked 1 are obstacles, and
the places marked 0 are accessible.
010000
000100
001001
110000
The entrance of the maze is the upper left corner, and the exit is the lower right corner. In the maze, you can only walk from one position to
one of its four directions, up, down, left and right.
For the maze above, starting from the entrance, you can pass through the maze in the order of DRRURRDDDR, a
total of 10 steps. Among them, D, U, L, and R mean go down, up, left, and right respectively.
For the following more complicated maze (30 rows and 50 columns), please find a way to go through the maze,
which uses the least number of steps. Under the premise of the least number of steps , please find the one with the least lexicographical order as the answer.
Please note that D<L<R<U in lexicographic order. (If you copy the following text into a text file, be sure
the content will be copied to check whether there is consistent with the document in a file directory questions maze.txt,
the same content with the following text)
01010101001011001001010110010110100100001000101010
00001000100000101010010000100000001001100110100101
01111011010010001000001101001011100011000000010000
01000000001010100011010000101000001010101011001011
00011111000000101000010010100010100000101100000000
11001000110101000010101100011010011010101011110111
00011011010101001001001010000001000101001110000000
10100000101000100110101010111110011000010000111010
00111000001010100001100010000001000101001100001001
11000110100001110010001001010101010101010001101000
00010000100100000101001010101110100010101010000101
11100100101001001000010000010101010100100100010100
00000010000000101011001111010001100000101010100011
10101010011100001000011000010110011110110100001000
10101010100001101010100101000010100000111011101001
10000000101100010000101100101101001011100000000100
10101001000000010100100001000100000100011110101001
00101001010101101001010100011010101101110000110101
11001010000100001100000010100101000001000111000010
00001000110000110101101000000100101001001000011101
10100101000101000000001110110010110101101010100001
00101000010000110101010000100010001001000100010101
10100001000110010001000010101001010101011111010010
00000100101000000110010100101001000001000000000010
11010000001001110111001001000011101001011011101000
00000110100010001000100000001000011101000000110011
10101000101000100010001111100010101001010000001000
10000010100101001010110000000100101010001011101000
00111100001000010000000110111000000001000000001011
10000001100111010111010001000110111010101101111000
[answer] submitted
This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is a string containing four letters D, U, L, and R. When submitting the answer, only fill in this string, and fill in the extra content will not be scored.
Topic analysis
topic codes



Question 6: Sum of Special Numbers

Title description
Xiao Ming is very interested in numbers containing 2, 0, 1, and 9 in the digits (excluding leading 0). Such numbers from 1 to 40 include 1, 2, 9, 10 to 32, 39 and 40, in total 28, their sum is 574.
Excuse me, what is the sum of all such numbers from 1 to n?
[Input format]
Input one line contains two integers n.
[Output format]
Output one line, including an integer, which represents the sum of the numbers that meet the conditions.
[Sample input]
40
[Sample output]
574
[Measurement use case scale and conventions]

For 20% of the evaluation use cases, 1≤n≤10.

For 50% of the evaluation use cases, 1≤n≤100.

For 80% of the evaluation use cases, 1≤n≤1000.

For all evaluation use cases, 1≤n≤10000.
Topic analysis
topic codes



Question 7: Priority of takeaway shops

The title describes
"Are you full?" There are N take-out shops maintained in the take-out system, numbered 1 ∼ N. Each takeaway store has a priority, and the priority is 0 at the beginning (at time 0).
Every time a unit of time has elapsed, if the takeaway store has no order, the priority will be reduced by 1, and the lowest will be reduced to 0; if the takeaway store has an order, the priority will not decrease but increase, and the priority will increase by 2 for each order.
If the priority of a takeaway restaurant is greater than 5 at a certain moment, it will be added to the priority cache by the system; if the priority is less than or equal to 3, it will be cleared from the priority cache.
Given the M pieces of order information within time T, please calculate how many takeaway shops are in the priority cache at time T.
[Input format] The
first line contains 3 integers N, M and T.
Each of the following M lines contains two integers ts and id, indicating that the takeaway store with the id at time ts received an order.
[Output format]
Output an integer to represent the answer.
[Sample input]
2 6 6
1 1
5 2
3 1
6 2
2 1
6 2
[Sample output]
1
[Sample explanation]
At time 6, the priority of No. 1 shop drops to 3 and is removed from the priority cache ; The priority of No. 2 shop is raised to 6, and priority cache is added. So there is 1 store (No. 2) in the priority cache.
[Measurement use case scale and convention]

For 80% of the evaluation cases, 1≤N,M,T ≤10000.
For all evaluation cases, 1≤N,M,T ≤100000, 1≤ts≤T, 1≤id ≤N.

Time limit: 1.0s

Memory limit: 512.0MB
question analysis
question code



Question 8: Character correlation analysis

Title description
Xiao Ming is analyzing the relevance of the characters in a novel. He wants to know how many times Alice and Bob appear together in the novel.
To be more precise, Xiaoming defined Alice and Bob to "appear at the same time" as meaning: There are no more than K characters between Alice and Bob in the novel text.
For example, the following text:
ThisisastoryaboutAliceandBob.AlicewantstosendaprivatemessagetoBob.
Assuming K = 20, then Alice and Bob appear twice at the same time, which are "Alice and Bob" and "Bob. Alice". The former has 5 characters between Alice and Bob, and the latter has 2 characters.
note:

  1. Alice and Bob are case sensitive, so alice or bob are not counted.
  2. Alice and Bob should be separate words, with punctuation marks and spaces before and after, but no letters. For example, Bobbi does not count as the appearance of Bob.
    [Input format] The
    first line contains an integer K.
    The second line contains a string of characters, containing only uppercase and lowercase letters, punctuation, and spaces. The length does not exceed 1000000.
    [Output format]
    Output an integer, representing the number of times Alice and Bob appear at the same time.
    [Sample input]
    20
    ThisisastoryaboutAliceandBob.AlicewantstosendaprivatemessagetoBob.
    [Sample output]
    2
    [Evaluation use case scale and conventions]
    For all evaluation use cases, 1≤K ≤1000000.
    Topic analysis
    topic codes


Question 9: Postfix expression

Title description
Given N plus signs, M minus signs, and N + M + 1 integers A1, A2,..., AN+M+1, Xiao Ming wants to know how many Which of the legal postfix expressions made up of numbers and N + M +1 integers has the largest result?
Please output this maximum result.
For example, if 1 2 3 +-is used, the result of the postfix expression "2 3 + 1 -" is 4, which is the largest.
[Input format] The
first line contains two integers N and M. The second line contains N + M + 1 integers A1, A2,...,AN+M+1.
[Output format]
Output an integer, representing the answer.
[Sample input]
1 1
1 2 3
[Sample output]
4
[Evaluation use case scale and conventions]
For all evaluation use cases, 0≤ N, M ≤100000, −109 ≤ Ai ≤109.
Topic analysis
topic codes



Question 10: Psionic Transmission

Title description
[topic background]

In the game "StarCraft II", the high-level templar, as an important AOE unit of the Protoss, plays an important role in the middle and late stages of the game. Its skill "Psionic Storm" can consume a large amount of psionic energy in an area. The enemy forces caused devastating damage. Often used to fight against human biochemical forces and Zerg Hydralisk and other low-health units.

【Problem Description】

You control n high-ranked templars, labeled 1,2,...,n for convenience. Every high-level templar needs a certain amount of psionic energy to fight, and each person has a psionic value ai, which indicates how much psionic energy he has (ai non-negative means that this high-level templar is more than in the best state If ai points psionic power, if ai is negative, it means that this high-level templar still needs −ai points psionic power to reach the best combat state). Now the system gives your high-level templars an ability to transfer psionic energy. Each time you can choose an i ∈ [2,n−1], if ai ≥ 0, then the high-level templars on both sides, that is i−1, i + 1 these two high-level templars will each draw ai points of psionic power from the high-level templar of i; if ai <0, the high-level templars on both sides, that is, i −1,i+1 These two high-level templars will give the high-level templar i -ai points of psionic power. Formally speaking, it is ai−1+ = ai, ai+1+ = ai, ai−= 2ai.

Psionic power is a very efficient combat tool. It is also very dangerous and unstable. It is not good for a high-level templar to have too much or too little psionic power. The instability of a group of high-level templars is defined as maxn i=1|ai|, please pass an unlimited number of psionic operations to minimize the instability of the group of high-level templars you control.

[Input format]

This question contains multiple sets of questions. The first line of input contains a positive integer T to indicate the number of query groups. Then enter each set of queries in turn. The first line of each group of queries contains a positive integer n, which represents the number of high-level templars. The next line contains n numbers a1, a2,...,an.

【Output Format】

Output T lines. An integer in each line indicates the answer to each group of queries in turn.

【Sample Input】

3
3
5 -2 3
4
0 0 0 0
3
1 2 3
【Sample output】

3
0
3

[Sample description]

For the first set of queries:
a1 = 3, a2 = 2, and a3 = 1 after the transmission operation to the No. 2 High Templar. The answer is 3.

For the second group of questions:
this group of high-ranking templars possesses the psionic power that can make them reach the best combat state.

[Sample input]
3
4
-1 -2 -3 7
4
2 3 4 -8
5
-1 -1 6 -1 -1

[Sample output]

5
7
4
Insert picture description here

Topic analysis
topic codes



Guess you like

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