2019 10th Java Group A Blue Bridge Cup Provincial Championship

Here is the topic column of the Blue Bridge Cup over the years. It will be updated successively and the real questions and answers of previous years will be released. I welcome you to follow me. Your likes and attention are the best motivation for me! ! !
The real questions are updated every day, so stay tuned

Blue Bridge Cup real questions and detailed answers over the years


First issue: sum of squares (5 minutes)

Title Description
Xiao Ming is very interested in numbers containing 2, 0, 1, and 9. Such numbers in 1 to 40 include 1, 2, 9, 10 to 32, 39 and 40, a total of 28, their sum is 574, and the sum of the squares is 14362. Note that the sum of squares means that each number is squared separately and then summed.
Excuse me, what is the sum of the squares of all such numbers from 1 to 2019?
topic analysis
topic code



Question 2: Sequence Evaluation (5 points)

Problem Description
Given a sequence of 1, 1, 1, 3, 5, 9, 17, …, starting from the 4th term, each term is the sum of the previous 3 terms. Find
the last 4 digits of item 20190324.
topic analysis
topic code



Question 3: Maximum rainfall (10 points)

Title Description
Due to the long-term drought in the land of sand, the mage Xiao Ming is going to cast one of his mysterious spells to ask for rain.
This spell requires 49 spell charms in his hand, with 49
numbers from 1 to 49 written on them. The spell lasts for a total of 7 weeks. Every day, Xiao Ming has to use a spell, and the spell cannot be used repeatedly.
Every week, the energy generated by Xiao Ming's spells is the median of the numbers on the 7 spells this week. After the spell
has been cast for 7 weeks, the rain request will be successful, with the rainfall being the median energy of the 7 weeks.
Due to the long drought, Xiao Ming hopes that the rainfall will be as large as possible this time. What is the maximum value please?
topic analysis
topic code



Question 4: Maze

Description of the topic
The following figure shows a plan view of a maze, in which the obstacles marked 1 are obstacles and the places marked 0 are accessible.

010000
000100
001001
110000

The entrance to the maze is the upper left corner and the exit is the lower right corner. In the maze, you can only go from one position to one of the four directions of up, down, left and right.
For the above maze, 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 represent going down, up, left, and right, respectively.
For the more complicated maze below (30 rows and 50 columns), find a way to go through the maze that uses the fewest steps, and find the answer with the smallest lexicographical order given the fewest steps. Note that D<L<R<U in the lexicographical order. (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 is a file maze.txt in the test question directory with the same content as the text below)

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

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, including four letters D, U, L, R. Only fill in this string when submitting the answer, and you will not be able to score if you fill in the extra content.
topic analysis

topic code



Question 5: RSA Decryption (15 points)

Title Description
RSA is a classic encryption algorithm. Its basic encryption process is as follows.
First generate two prime numbers p, q, let n = p · q, set d and (p − 1) · (q − 1) coprime, then we can find e such that d · e divides (p − 1) · (q − 1) has a remainder of 1.
n, d, e make up the private key, and n, d make up the public key.
When using the public key to encrypt an integer X (less than n), calculate C = Xd mod n, then C is the encrypted ciphertext.
When the ciphertext C is received, it can be decrypted using the private key, and the calculation formula is X = Ce mod n. For example, when p = 5, q = 11, d = 3, n = 55, e = 27.
If you encrypt the number 24, you get 243 mod 55 = 19. Decrypt the number 19 and get 1927 mod 55 = 24.
Now you know that n = 1001733993063167141, d = 212353 in the public key, and you have intercepted the ciphertext C = 20190324 sent by others. Excuse me, what is the original text?
topic analysis
topic code



Question 6: Weights of Complete Binary Trees (15 points)

Title Description
Given a complete binary tree containing N nodes, each node in the tree has a weight, which are A1, A2, · · · AN in order from top to bottom and left to right, as shown in the following figure Shown:
Now Xiaoming wants to add the weights of nodes of the same depth together. He wants to know which depth has the largest sum of the weights of nodes? If there are multiple depths with the same maximum weight, please output the smallest depth.
Note: The depth of the root is 1.
【Input format】
The first line contains an integer N.
The second row contains N integers A1, A2, · · · AN.
【Output format】
Output an integer to represent the answer.
[Sample input]
7
1 6 5 4 3 2 1
[Sample output]
2
[Evaluation case scale and convention]
For all evaluation cases, 1 ≤ N ≤ 100000, −100000 ≤ Ai ≤ 100000.

topic analysis
topic code



Question 7: Priority of takeaway stores (20 points)

Title description
"Are you full?" There are N takeaway stores maintained in the takeaway system, numbered 1∼N. Each takeaway store has a priority, and the priority is 0 at the beginning (at time 0).
Every time unit elapses, if there is no order in the takeaway store, the priority will be reduced by 1, and the lowest will be reduced to 0; and if there is an order in the takeaway store, the priority will not decrease but increase, and the priority will increase by 2 for each order.
If the priority of a takeaway store is greater than 5 at a certain time, 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 out of the priority cache.
Given M order information within time T, please calculate how many takeaway stores 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 the moment of 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 store drops to 3 and is removed from the priority cache ; No. 2 store's priority is upgraded to 6, and the priority cache is added. So there is 1 store (No. 2) in the priority cache.
[Scale and conventions of evaluation use cases]
For 80% of evaluation use cases, 1 ≤ N, M, T ≤ 10000.
For all evaluation cases, 1 ≤ N, M, T ≤ 100000, 1 ≤ ts ≤ T , 1 ≤ id ≤ N.
topic analysis
topic code



Question 8: Modifying an Array (20 points)

Problem Description
Given an array A = [A1, A2, · · · AN] of length N, there may be repeated integers in the array.
Now Xiaoming wants to modify it into an array without repeating integers as follows. Xiao Ming will modify
A2, A3, · · · , AN in turn.
When modifying Ai, Xiaoming will check whether Ai has appeared in A1 ∼ Ai−1. If it has appeared, Xiaoming will add 1 to Ai; if the new Ai has appeared before, Xiaoming will continue to add 1 to Ai until Ai has not appeared in A1 ∼ Ai−1.
When AN is also modified as above, obviously there are no repeated integers in the A array. Now given the initial A array, please calculate the final A array.
【Input format】
The first line contains an integer N.
The second row contains N integers A1, A2, · · · , AN .
[Output format]
Output N integers, followed by the final A1, A2, · · · , AN.
[Sample input]
5
2 1 1 3 4
[Sample output]
2 1 3 4 5
[Evaluation case scale and convention]
For 80% of the evaluation use cases, 1 ≤ N ≤ 10000.
For all evaluation cases, 1 ≤ N ≤ 100000, 1 ≤ Ai ≤ 1000000.
topic analysis
topic code



Question 9: Candy (25 points)

Title Description
The owner of a candy store sells M flavors of candy. For the convenience of description, we number the M flavors 1 ∼ M.
Xiao Ming wants to taste all flavors of candy. It's a pity that the boss doesn't sell candies individually, but sells them in packs of K pieces.
Fortunately, the flavors of the K pieces of candy are marked on the candy packaging, so Xiao Ming can know the flavors of the candies in each package before buying.
Given N packs of candy, please calculate the minimum number of packs that Xiao Ming buys, so that he can taste all flavors of candy.
【Input format】
The first line contains three integers N, M and K.
Next N lines, each line of K, the integers T1, T2, · · · , TK, represent the flavors of a pack of candy.
[Output format]
An integer represents the answer. If Xiao Ming cannot taste all the flavors, output −1.
[Sample input]
6 5 3
1 1 2
1 2 3
1 1 3
2 3 5
5 4 2
5 1 2
[Sample output]
2
[Evaluation case scale and convention]
For 30% of the evaluation cases, 1 ≤ N ≤ 20.
For all evaluation samples, 1 ≤ N ≤ 100, 1 ≤ M ≤ 20, 1 ≤ K ≤ 20, 1 ≤ Ti ≤ M.
topic analysis
topic code



Question 10: Combination number problem (25 points)

Problem Description
Given n, m, k, find how many pairs of (i, j) satisfy 1 ≤ i ≤ n, 0 ≤ j ≤ min(i, m) and C j ≡
0(mod k), where k is a prime number. where C j is the number of combinations, indicating the number of solutions that select j from i different numbers to form
a set.
[Input format]
There are two numbers t, k in the first line, where t represents that the test point contains t groups of queries, and the meaning of k is the same as the above.
The next t lines each contain two integers n, m, representing a set of queries.
[Output format]
Output t lines, each line is an integer representing the corresponding answer. Since the answer can be large, print the remainder of dividing the answer by 109 + 7.
[Sample input]
1 2
3 3
[Sample output]
1
[Sample description]
In all possible cases, only C1 = 2 is a multiple of 2.
[Sample input]
2 5
4 5
6 7
[Sample output]
0
7
[Sample input]
3 23
23333333 23333333
233333333 233333333
2333333333 2333333333
[Sample output]
851883128
959557926
680723120
[Data scale and conventions]
For all evaluation cases, 1 ≤ k ≤ 108, 1 ≤ t ≤ 105, 1 ≤ n, m ≤ 1018, and k is a prime number. The evaluation will use 10 evaluation cases to test your program, each evaluation case is limited as follows:

Evaluation case number tn, mk
1, 2 ≤ 1 ≤ 2000 ≤ 100
3, 4 ≤ 105 ≤ 2000 ≤ 100
5, 6, 7 ≤ 100 ≤ 1018 ≤ 100
8, 9, 10 ≤ 105 ≤ 1018 ≤ 108
item analysis
item code



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324683278&siteId=291194637