2019 10th C/C++ Group A Blue Bridge Cup Provincial Competition Real Questions

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: Sum of Squares

Title description
Xiao Ming is very interested in the numbers containing 2, 0, 1, 9 in the digits. Such numbers from 1 to 40 include 1, 2, 9, 10 to 32, 39 and 40, 28 in total, and their sum It is 574, and the sum of squares is 14362. Note that the sum of squares means that each number is squared separately and then summed.
May I ask, from 1 to 2019, what is the sum of squares of all such numbers?
Topic analysis
topic codes



Question 2: 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.
Topic analysis
topic codes



Question 3: Maximum rainfall

Title Description
Due to the years of drought in the Land of Sand, the wizard Xiao Ming is preparing to cast a mysterious spell of his own to pray 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 7 weeks, and Xiao Ming uses a spell talisman every day. The spell talisman cannot be reused. Every week, the energy produced by Xiaoming's spells is the median of the numbers on the 7 spell symbols this week. After 7 weeks of casting the spell, the rain request will be successful, and the rainfall is the median energy of 7 weeks. Due to the drought for too long, Xiao Ming hopes that the rainfall for this request will be as large as possible. What is the maximum value?
Topic analysis
topic codes



Fourth question: Labyrinth

Title description
The figure below shows a plan view of a maze, where the obstacles marked 1 are obstacles, and the places marked 0 are passable places.

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.

[Data given by the title]

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

Topic analysis
topic codes



Question 5: RSA decryption

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) to be relatively prime, then you can find e such that d · e divides (p − 1) · (q − The remainder of 1) is 1. n, d, e constitute the private key, and n, d constitute the public key. When using a 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 unlocked with the private key. The calculation formula is X = Ce mod n. For example, when p = 5, q = 11, d = 3, n = 55, e = 27. If the number 24 is encrypted, 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 intercepted the cipher text C = 20190324 sent by others. What is the original text?
Topic analysis
topic codes



The sixth question: the weight of the complete binary tree

Title description
Given a complete binary tree containing N nodes, each node on the tree has a weight, which is A1, A2, · · · AN
now , in order from top to bottom and left to right Adding the weights of nodes of the same depth together, he wants to know which depth has the largest sum of weights? If there are multiple depths with the same weight and the same maximum, please output the smallest depth.
Note: The depth of the root is 1.
[Input format] The
first line contains an integer N.
The second line 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
topic analysis
topic code



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
topic analysis
topic code



Question 8: Modify the array

Title description
Given an array A = [A1, A2, · · · AN] of length N, there may be repeated integers in the array.
Now Xiao Ming needs to modify it to an array without repeated integers in the following way. Xiao Ming will modify
A2, A3, · · ·, AN in sequence .
When modifying Ai, Xiao Ming will check whether Ai has appeared in A1 ∼ Ai−1. If it has appeared, Xiao Ming will add 1 to Ai; if the new Ai has appeared before, Xiao Ming will continue to add 1 to Ai until Ai has not appeared in A1 ∼ Ai−1.
When AN has also undergone the above modification, it is obvious that 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 line 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
Item analysis
item code



Question 9: Candy

Title description
The owner of the candy store sells a total of M flavors of candy. For the convenience of description, we number M flavors from 1 to M.
Xiao Ming hopes to taste all kinds of sweets. It is a pity that the boss does not sell candies individually, but K pieces in a package.
Fortunately, the flavor of the K candies is indicated on the candy packaging, so Xiao Ming can know the flavor of the candy in each packet before buying it.
Given N packs of candies, please calculate how many packs Xiao Ming buys at least so that you can taste all kinds of candies.

[Input format] The
first line contains three integers N, M and K.
The integers T1, T2, · · ·, TK represent the taste 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
topic analysis
topic code



Question 10: The number of combinations

Problem description
Given n, m, k, find how many pairs (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, which means that j out of i different numbers are selected to form
a set of solutions.
[Input format]
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 above.
In the next t line, each line contains two integers n, m, representing a set of queries.
[Output format]
Output t lines, with an integer in each line representing the corresponding answer. Since the answer may be large, please output the remainder of the answer divided by 109 + 7.
[Sample input]
1 2
3 3
[Sample output]
1
[Sample description]
In all possible situations, 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
topic analysis
topic code



Guess you like

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