The second game of the 11th Blue Bridge Cup Software Provincial Competition (C/C++ University Group B)

Question A: House number making

Total score for this question: 5 points
[Problem description]
Xiaolan wants to make house numbers for households in a street.
There are a total of 2020 households on this street, and the house numbers are numbered from 1 to 2020.
The method for Xiaolan to make the house plate is to make the number characters from 0 to 9 first, and finally
paste the characters on the house plate as needed. For example, house plate 1017 needs to paste the characters 1,
0 , 1, 7 in sequence, that is, 1 character 0 , 2 characters 1, 1 character 7.
How many characters 2 are required to make all the number 1 to 2020?
[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. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.

Question B: Conventional score

Total score for this question: 5 points
[Problem description]
If the greatest common divisor of the numerator and denominator of a fraction is 1, this fraction is called a reduced fraction.
For example, 3/4, 5/2, 1/8, and 7/1
are all reduced scores.
Excuse
me , how many reduced fractions, whose numerator and denominator are both integers between 1 and 2020 (including 1 and 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.

Test Question C: Snake-shaped fill in the number

Total score for this question: 10 points
[Problem description]
As shown in the figure below, Xiaoming fills the infinite matrix with a "snake shape" of positive integers starting from 1.
1 2 6 7 15…
3 5 8 14…
4 9 13…
10 12…
11
……
(1) It is
easy to see that the number in the second row and second column of the matrix is ​​5. Could you please calculate
the number in the 20th row and 20th column of the matrix ?
[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. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.

Test Question D: Running Exercise

Total score for this question: 10 points
[Problem description]
Xiaolan exercises every day.
Under normal circumstances, Xiaolan runs 1 kilometer every day. If a day is Monday or the beginning of the month (1st), in order to
motivate herself, Xiao Lan will run 2 kilometers. If it is also Monday or the beginning of the month, Xiaolan will also run 2 kilometers.
Xiaolan has been running for a long time, from Saturday, January 1, 2000 (inclusive) to
Thursday , October 1, 2020 (inclusive). How many kilometers did Xiaolan run during this period?
[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. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.

Question E: Seven-segment code

Total score for this question: 15 points
[Problem description]
Xiaolan uses a seven-segment digital tube to express a special kind of text.
The figure above shows an illustration of a seven-segment digital tube. There are 7 LEDs in the digital tube that can emit light
, which are marked as a, b, c, d, e, f, g.
Xiaolan chooses a part of the diode (at least one) to emit light to express characters. When designing
the expression of characters , all light-emitting diodes are required to be connected in one piece.
For example: b is illuminated, and other diodes do not emit light, which can be used to express a character.
For example: c light-emitting, other diodes not light-emitting can be used to express a character. This scheme and
the scheme on the previous line can be used to represent different characters, although they look similar.
For example: a, b, c, d, e glow, f, g not glow can be used to express a character.
For example: b and f are light-emitting. If other diodes are not light-emitting, they cannot be used to express a character because the light-emitting
diodes are not connected together.
Excuse me, how many different characters can Xiaolan express with a seven-segment digital tube?
[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. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.

Question F: Score Statistics

Time limit: 1.0s Memory limit: 256.0MB Total score for this question: 15 points
[Problem description]
Xiaolan organized an exam for the students, the total score is 100 points, each student's score is
a 0 to 100 Integer.
If the score is at least 60 points, it is called a pass. If the score is at least 85 points, it is called excellent.
Please calculate the passing rate and the excellent rate and express them as a percentage. The part before the percentage sign is rounded to the nearest whole
number.
[Input format]
The first line of input contains an integer n, which represents the number of people in the exam.
In the next n rows, each row contains an integer from 0 to 100, representing a student's score.
[Output format]
Output two lines, each line with a percentage, respectively representing the passing rate and the excellent rate. The part before the percent sign is
rounded to the nearest whole number.
[Sample input]
7
80
92
56
74
88
100
0

[Sample output]
71%
43%
[Evaluation use case scale and conventions]
For 50% of evaluation use cases, 1 ≤ n ≤ 100.
For all evaluation use cases, 1 ≤ n ≤ 10000.

Question G: Palindrome Date

Time limit: 1.0s Memory limit: 256.0MB Total score for this question: 20 points
[Problem description]
During the Spring Festival in 2020, there is a special date that attracted everyone's attention: February 2
, 2020 . Because if this date is written as an 8-digit number in the format of "yyyymmdd", it is 20200202, which
happens to be a palindrome number. We call such a date a palindrome date.
Some people say that 20200202 is a special day of "one encounter in a thousand years". Xiao Ming
strongly disagrees with this, because less than 2 years later is the next palindrome date: 20211202, which is December 2, 2021.
It was also said that 20200202 is not just a palindrome date, but an ABABBABA
-type palindrome date. Xiaoming also disagrees with this, because about 100 years later, he will encounter the next
ABABBABA palindrome date: 21211212, which is December 12, 2121. It's not a "
one encounter in a thousand years", but a "two encounters in a thousand years" at best.
Given an 8-digit date, please calculate the next palindrome date and the next
ABABBABA palindrome date after the date.
[Input format] The
input contains an eight-digit integer N, which represents the date.
[Output format]
Output two lines, each line has an eight-digit number. The first line represents the date of the next palindrome, and the second line represents the date of the next
ABABBABA palindrome.
[Sample input]
20200202
[Sample output]
20211202
21211212
[Evaluation use case scale and convention]
For all evaluation use cases, 10000101 ≤ N ≤ 89991231, to ensure that N is an
8-digit representation of a legal date .

Test question H: substring score sum

Time limit: 1.0s Memory limit: 256.0MB Total score for this question: 20 points
[Problem description]
For a string S, we define the score f(S) of S as the
number of different characters in S. For example, f("aba") = 2, f("abc") = 3, f("aaa") = 1.
Now given a string S [0 ... n - 1] ( of length n), is calculated for a non-empty you all the S
substring S [i ... j] (0 ≤ i ≤ j <n), f (S What is the sum of [i… j]).
[Input format]
Input a line containing a string S consisting of lowercase letters.
[Output format]
Output an integer to represent the answer.
[Sample input]
ababc
[Sample output]
28
[Sample description]
Substring f value
a 1
ab 2
aba 2
abab 2
ababc 3
b 1
ba 2
bab 2
babc 3
a 1
ab 2
abc 3
b 1
bc 2
c 1
[Evaluation use case scale and agreement]
For 20% of evaluation use cases, 1 ≤ n ≤ 10;
For 40% of the evaluation cases, 1 ≤ n ≤ 100;
for 50% of the evaluation cases, 1 ≤ n ≤ 1000;
for 60% of the evaluation cases, 1 ≤ n ≤ 10000;
for all evaluation cases, 1 ≤ n ≤ 100000.

Test Question I: Plane Segmentation

Time limit: 1.0s Memory limit: 256.0MB Total score for this question: 25 points
[Problem description]
There are N straight lines on the plane, and the i-th straight line is y = Ai
· x + Bi.
Please calculate that these straight lines divide the plane into several parts.
[Input format] The
first line contains an integer N.
The following N lines, each line contains two integers Ai
and Bi.
[Output format]
An integer represents the answer.
[Sample input]
3
1 1
2 2
3 3
[Sample output]
6
[Evaluation use case scale and conventions]
For 50% of evaluation use cases, 1 ≤ N ≤ 4, −10 ≤ Ai
, Bi ≤ 10.
For all evaluation cases, 1 ≤ N ≤ 1000, −100000 ≤ Ai
, Bi ≤ 100000.

Question J: String sorting

Time limit: 1.0s Memory limit: 256.0MB Total score for this question: 25 points
[Problem description]
Xiaolan recently learned some sorting algorithms, among which bubble sorting impressed him.
In bubble sorting, only two adjacent elements can be exchanged at a time.
Xiaolan found that if the characters in a string are sorted and only two adjacent characters are allowed to be exchanged
, the total number of exchanges for bubble sorting is the least among all possible sorting schemes.
For example, for sorting the string lan, only 1 exchange is required. For the string qiao sorting,
a total of 4 exchanges are required.
Xiaolan's lucky number is V. He wants to find a string containing only lowercase English letters, and
sort the characters in this string by bubbling, which requires exactly V exchanges. Please help Xiaolan find such a
string. If you can find more than one, please tell Xiaolan the shortest one. If there are still multiple shortest ones,
please tell Xiaolan the one with the smallest lexicographical order. Please note that the same characters can be included in the string.
[Input format]
Input a line containing an integer V, which is Xiaolan's lucky number.
[Output format]
Output a string, which is the answer to the request.
[Sample input]
4
[Sample output]
bbaa
[Sample input]
100
[Sample output]
jihgfeeddccbbaa
[Evaluation use case scale and conventions]
For 30% of evaluation use cases, 1 ≤ V ≤ 20.
For 50% of the evaluation use cases, 1 ≤ V ≤ 100.
For all evaluation use cases, 1 ≤ V ≤ 10000.

Guess you like

Origin blog.csdn.net/qq_46009744/article/details/109208550