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
table of Contents
Question 1: Shopping list
Title description
Xiao Ming just got a job. The boss is very nice, but the boss's wife loves shopping. When the boss is busy, he often asks Xiao Ming to help him go shopping on his behalf. Xiao Ming was bored, but he couldn't refuse.
No, the XX promotion is here again! The wife of the boss issued a long shopping list, all with discounts. Xiao Ming also has a quirk. He never swipes his card as a last resort, and can get it with cash.
Now Xiao Ming is very upset. Please help him calculate how much cash he needs to withdraw from the ATM to complete this shopping.
The ATM can only provide 100 yuan banknotes. Xiao Ming wants to withdraw as little cash as possible, just enough.
Your task is to figure out how much cash Xiao Ming needs to withdraw at least.
The following is a headache shopping list. In order to protect privacy, the names of the items are hidden.
**** 180.90 12% off **** 10.25 65% off **** 56.14 10% off **** 104.65 10% off **** 100.30 88% off **** 297.15 half price **** 26.75 35 % off ** ** 130.62 half price **** 240.28 58% off **** 270.62 20% off **** 115.87 12% off **** 247.34 5% off **** 73.21 10% off **** 101.00 half price **** 79.54 Half price **** 278.44 30% off **** 199.26 Half price **** 12.97 10% off **** 166.30 78% off **** 125.50 58% off **** 84.98 10% off **** 113.35 68% off **** 166.57 half price **** 225.87 75% off **** 42.56 10% off **** 81.90 5% off **** 131.78 20% off **** 255.89 78% off **** 109.17 10% off **** 146.69 68% off **** 139.33 65% off * *** 141.16 78% off **** 154.74 20% off **** 59.42 20% off **** 85.44 68% off **** 293.70 88% off **** 261.79 65% off **** 11.30 88% off ** ** 268.27 58% off **** 128.29 12% off **** 251.03 20% off **** 208.39 75% off **** 128.88 75% off **** 62.06 10% off **** 12.89 75% off *** * 34.28 75% off **** 62.16 58% off **** 129.12 half price **** 218.37 half price **** 289.69 20% off
It should be noted that the 88% discount is calculated at 88% of the list price, while the 20% discount is calculated at 80%, and the rest is analogous.
In particular, half price is calculated at 50%.
Please submit the amount Xiao Ming wants to withdraw from the ATM, in yuan.
The answer is an integer, similar to 4300, and must end with 00. Do not fill in any extra content.
Topic analysis
topic codes
Question 2: The Triangle of Cards
Title description
A,2,3,4,5,6,7,8,9 9 cards are arranged in an equilateral triangle (A is calculated as 1). The sum of each side is required to be equal.
The figure below is a sorting method (if there is an alignment problem, see p1.png).
A 9 6 4 8 3 7 5 2
There may be many such arrangements.
If you consider the same type of rotation and mirroring, how many different arrangements are there?
Please calculate and submit this figure.
Note: What needs to be submitted is an integer, do not submit any extra content.
Topic analysis
topic codes
The third question: pressure calculation
The title describes
a certain batch of precious metal raw materials neatly stacked in the high-tech laboratory of Planet X.
The shape and size of each metal raw material are exactly the same, but the weight is different.
The metal materials are stacked strictly in a pyramid shape.
7 5 8 7 8 8 9 2 7 2 8 1 4 9 1 8 1 8 8 4 1 7 9 6 1 4 5 4 5 6 5 5 6 9 5 6 5 5 4 7 9 3 5 5 1 7 5 7 9 7 4 7 3 3 1 4 6 4 5 5 8 8 3 2 4 3 1 1 3 3 1 6 6 5 5 4 4 2 9 9 9 2 1 9 1 9 2 9 5 7 9 4 3 3 7 7 9 3 6 1 3 8 8 3 7 3 6 8 1 5 3 9 5 8 3 8 1 8 3 3 8 3 2 3 3 5 5 8 5 4 2 8 6 7 6 9 8 1 8 1 8 4 6 2 2 1 7 9 4 2 3 3 4 2 8 4 2 2 9 9 2 8 3 4 9 6 3 9 4 6 9 7 9 7 4 9 7 6 6 2 8 9 4 1 8 1 7 2 1 6 9 2 8 6 4 2 7 9 5 4 1 2 5 1 7 3 9 8 3 3 5 2 1 6 7 9 3 2 8 9 5 5 6 6 6 2 1 8 7 9 9 6 7 1 8 8 7 5 3 6 5 4 7 3 4 6 7 8 1 3 2 7 4 2 2 6 3 5 3 4 9 2 4 5 7 6 6 3 2 7 2 4 8 5 5 4 7 4 4 5 8 3 3 8 1 8 6 3 2 1 6 2 6 4 6 3 8 2 9 6 1 2 4 1 3 3 5 3 4 9 6 3 8 6 5 9 1 5 3 2 6 8 8 5 3 2 2 7 9 3 3 2 8 6 9 8 4 4 9 5 8 2 6 3 4 8 4 9 3 8 8 7 7 7 9 7 5 2 7 9 2 5 1 9 2 6 5 3 9 3 5 7 3 5 4 2 8 9 7 7 6 6 8 7 5 5 8 2 4 7 7 4 7 2 6 9 2 1 8 2 9 8 5 7 3 6 5 9 4 5 5 7 5 5 6 3 5 3 9 5 8 9 5 4 1 2 6 1 4 3 5 3 2 4 1 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
The number represents the weight of the metal block (larger unit of measurement).
The X on the bottom layer represents 30 extremely high-precision electronic scales.
Assuming that the weight of each piece of raw material falls on the two metal blocks below it very accurately, and
finally, the weight of all the metal blocks is strictly and accurately divided equally on the bottom electronic scale.
The measurement unit of the electronic scale is very small, so the displayed number is very large.
The staff found that the reading of the electronic scale with the smallest reading was 2086458231
Please calculate: What is the reading of the electronic scale with the largest reading?
Note: What needs to be submitted is an integer, do not fill in any extra content.
Topic analysis
topic codes
Fourth question: Rubik's cube state
Title description The
second-order Rubik's Cube is a Rubik's Cube with only 2 layers, consisting of only 8 small pieces.
As shown in figure p1.png.
Xiao Ming is very naughty. He only likes 3 colors, so he repainted the second-order Rubik's Cube at home, as follows:
Front: Orange
Right: Green
Top: Yellow
Left: Green
Below: Orange
Back: Yellow
Please calculate how many different states there are after such a Rubik's Cube is disrupted.
If the two states after the overall rotation of the Rubik's Cube, the colors of all sides are the same, it is considered the same state.
Please submit an integer representing the number of states, and do not fill in any redundant content or explanatory text.
Topic analysis
topic codes
Question 5: Take the number
Title Description
There are many ways to find the k-th digit of an integer.
The following method is one.
public class Main
{
static int len(int x){
if(x<10) return 1;
return len(x/10)+1;
}
// 取x的第k位数字
static int f(int x, int k){
if(len(x)-k==0) return x%10;
return ______________________; //填空
}
public static void main(String[] args)
{
int x = 23513;
//System.out.println(len(x));
System.out.println(f(x,3));
}
}
For the test data in the question, 5 should be printed.
Please analyze the source code carefully, and add the missing code in the underlined part.
Topic analysis
topic codes
Question 6: The largest common substring
Title description The problem of the
maximum common substring length is: what
is the maximum length that can be matched among all substrings of two strings.
For example: "abcdkkk" and "baabcdadabc",
the longest common substring that can be found is "abcd", so the maximum common substring length is 4.
The following program is solved by the matrix method, which is a relatively effective solution for the case where the string size is not large.
public class Main
{
static int f(String s1, String s2)
{
char[] c1 = s1.toCharArray();
char[] c2 = s2.toCharArray();
int[][] a = new int[c1.length+1][c2.length+1];
int max = 0;
for(int i=1; i<a.length; i++){
for(int j=1; j<a[i].length; j++){
if(c1[i-1]==c2[j-1]) {
a[i][j] = __________________; //填空
if(a[i][j] > max) max = a[i][j];
}
}
}
return max;
}
public static void main(String[] args){
int n = f("abcdkkk", "baabcdadabc");
System.out.println(n);
}
}
Please analyze the idea of the solution and fill in the missing code in the underlined part.
Topic analysis
Topic code
Question 7: Date issue
Title description
Xiao Ming is collating a batch of historical documents. Many dates appear in these historical documents. Xiao Ming knows that these dates are from January 1, 1960 to December 31, 2059. What troubles Xiaoming is that the format of these dates is very inconsistent, some use year/month/day, some use month/day/year, and some use day/month/year. What is more troublesome is that the first two digits of the year are also omitted, so that there are many possible dates corresponding to a date in the literature.
For example, 02/03/04 may be March 04, 2002, February 03, 2004, or March 02, 2004.
Given a date in the literature, can you help Xiao Ming determine which possible dates correspond to it?
enter
A date, the format is "AA/BB/CC". (0 <= A, B, C <= 9)
enter
Output several different dates, one line for each date, the format is "yyyy-MM-dd". Multiple dates are arranged from morning to night.
Sample input
02/03/04
Sample output
2002-03-04
2004-02-03
2004-03-02
Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <1000ms
Topic analysis
topic codes
Question 8: Buns make up the number
Title description
Xiao Ming eats breakfast at a bun shop almost every morning. He found that this steamed bun was shopped with N kinds of steamers, of which the i-th steamer could hold Ai buns. Each kind of steamer has a lot of baskets, which can be regarded as infinite baskets.
Whenever a customer wants to buy X steamed buns, the uncle who sells steamed buns will quickly select a number of steamed steamed buns, so that there are exactly X steamed steamed buns in these several cages. For example, there are 3 kinds of steamers, which can hold 3, 4, and 5 buns. When a customer wants to buy 11 buns, the uncle will choose 2 cages of 3 plus 1 cage of 5 (or maybe 1 cage of 3 plus 2 cages of 4).
Of course, sometimes Uncle Baozi can't make up the amount the customer wants to buy. For example, there are 3 kinds of steamers, which can hold 4, 5, and 6 buns. When the customer wanted to buy 7 buns, the uncle couldn't get it together.
Xiao Ming wanted to know how many kinds of numbers Uncle Bao could not make up.
enter
The first line contains an integer N. (1 <= N <= 100)
Each of the following N lines contains an integer Ai. (1 <= Ai <= 100)
Output
An integer represents the answer. If the number that cannot be made up is infinite, output INF.
For example,
enter:
2
4
5
The program should output:
6
For another example,
enter:
2
4
6
The program should output:
INF
Sample explanation:
For sample 1, the unfinished numbers include: 1, 2, 3, 6, 7, 11.
For example 2, all odd numbers cannot be made up, so there are infinitely many.
Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <1000ms
topic analysis
topic code
Question 9: Divide Chocolate
Topic description On
Children's Day, K children visited Xiao Ming's house. Xiao Ming took out a collection of chocolates to entertain the children.
Xiao Ming has N pieces of chocolate in total, of which the i-th piece is a rectangle composed of Hi x Wi squares.
为了公平起见,小明需要从这 N 块巧克力中切出K块巧克力分给小朋友们。切出的巧克力需要满足:
1. 形状是正方形,边长是整数
2. 大小相同
For example, a piece of 6x5 chocolate can cut 6 pieces of 2x2 chocolate or 2 pieces of 3x3 chocolate.
Of course, the kids all hope that the chocolate they get is as big as possible. Can you help Little Hi calculate the maximum side length?
Input The
first line contains two integers N and K. (1 <= N, K <= 100000)
Each of the following N lines contains two integers Hi and Wi. (1 <= Hi, Wi <= 100000)
Enter to ensure that each child can get at least a 1x1 chocolate.
Output
Output the maximum possible side length of the cut square chocolate.
Sample input:
2 10
6 5
5 6
Sample output:
2
Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <1000ms
Topic analysis
topic codes
Tenth question: k times interval
Title Description
Given a sequence of length N, A1, A2,… AN, if the sum of a continuous sub-sequence Ai, Ai+1,… Aj(i <= j) is a multiple of K, we call this The interval [i, j] is the K times interval.
Can you find the total number of K-fold intervals in the sequence?
enter
The first line contains two integers N and K. (1 <= N, K <= 100000)
Each of the following N lines contains an integer Ai. (1 <= Ai <= 100000)
Output
Output an integer, representing the number of K times interval.
For example,
enter:
5 2
1
2
3
4
5
The program should output:
6
Resource agreement:
peak memory consumption (including virtual machine) <256M
CPU consumption <2000ms
question analysis
question code