2017 8th Java Group B Blue Bridge Cup Provincial Competition Real Questions

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


Question 1: Shopping list

Topic description
Xiao Ming has just found 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 go to the mall to do shopping on his behalf. Xiao Ming was very tired, but he couldn't refuse.
No, the XX promotion is here again! The boss's wife opened a long shopping list, all with discounts. Xiao Ming also has a quirk. Unless it is a last resort, he never swipes his card and gets it directly in cash.
Xiao Ming is very upset now. Please help him calculate how much cash he needs to withdraw from the ATM to complete this shopping.
ATMs can only provide 100-yuan banknotes. Xiao Ming wants to withdraw as little cash as possible, as long as it is enough.
Your task is to calculate the minimum amount of cash that Xiao Ming needs to withdraw.
Here's a vexing shopping list, with item names hidden for privacy.

**** 180.90 12% off
**** 10.25 45% off
**** 56.14 10% off
**** 104.65 10% off
**** 100.30 12% off
**** 297.15 half price
**** 26.75 45% off
**** 130.62 half price
**** 240.28 52% 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 22% off
**** 125.50 52% off
**** 84.98 10% off
**** 113.35 42% off
**** 166.57 half price
**** 42.56 10% off
**** 81.90 5% off
**** 131.78 20% off
**** 255.89 22% off
**** 109.17 10% off
**** 146.69 42% off
**** 139.33 45% off
**** 141.16 22% off
**** 154.74 20% off
**** 59.42 20% off
**** 85.44 42% off
**** 293.70 12% off
**** 261.79 45% off
**** 11.30 12% off
**** 268.27 52% off
**** 128.29 12% off
**** 251.03 20% off
**** 208.39 25% off
**** 128.88 25% off
**** 62.06 10% off
**** 225.87 25% off
**** 12.89 25% off
**** 34.28 25% off
**** 62.16 52% off
**** 129.12 half price
**** 218.37 half price
**** 289.69 20% off

It should be noted that the 88% discount refers to 88% of the list price, while the 20% discount is calculated at 80%, and the rest are analogous.
In particular, half price is calculated at 50%.

Please submit the amount that Xiao Ming wants to withdraw from the ATM, in yuan.
The answer is an integer, similar to 4300, the end must be 00, do not fill in any extra content.
topic analysis
topic code



Question 2: The Triangle of Cards

Title Description
A, 2, 3, 4, 5, 6, 7, 8, 9 A total of 9 cards are arranged in a regular triangle (A is counted as 1). The sum of each side is required to be equal.
The following figure is a kind of arrangement (if there is an alignment problem, please refer to p1.png).

      A
     9 6
    4   8
   3 7 5 2

There may be many such arrangements.
If you consider rotation and mirror images, the same ones are considered to be the same type. How many different arrangements are there in total?

Please calculate and submit this number.

Note: what needs to be submitted is an integer, do not submit anything redundant.
topic analysis
topic code



Question 3: 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 piece of metal raw material are exactly the same, but the weight is different.
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 in it represents the weight of the metal block (the larger unit of measure).
The X on the bottom layer represents 30 extremely high-precision electronic scales.

Assuming that the weight of each piece of raw material falls equally on the two metal pieces below it, in the
end, the weight of all metal pieces falls on the bottom electronic scale strictly and precisely.
Electronic scales have small units of measurement, so the numbers displayed are 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 redundant content.
topic analysis
topic code



Question 4: Rubik's Cube State

Title description
The second-order Rubik's Cube is a Rubik's Cube with only 2 layers and consists 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
Bottom: Orange
Back: Yellow

Please calculate how many different states there are after such a Rubik's Cube is disrupted.

If the two states have the same color on each surface after the overall rotation of the Rubik's cube, they are considered to be the same state.
insert image description here

Please submit an integer representing the number of states without any extra or explanatory text.
topic analysis
topic code



Question 5: Take Digits

Problem Description
There are many ways to find the kth 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 code



Question 6: Maximum Common Substring

Topic description The
maximum common substring length problem is to
find the maximum length of all substrings of two strings that can be matched.
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 more effective solution for the case where the size of the string 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 ​​this solution and complete the missing code in the underlined part.
topic analysis

topic code



Question 7: Date Questions

Topic description
Xiao Ming is sorting out 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 Xiao Ming 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's 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, it may be March 04, 2002, February 3, 2004, or March 02, 2004.

Given a date in the literature, can you help Xiao Ming determine what possible dates correspond to it?

enter

A date in the format "AA/BB/CC". (0 <= A, B, C <= 9)

enter

Output several different dates, one line for each date, in the format "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 convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 1000ms

topic analysis
topic code



Question 8: Buns make up the number

Title Description
Xiao Ming eats breakfast at a steamed bun shop almost every morning. He found that this steamed bun shop has N kinds of steamers, and the i-th steamer can hold Ai buns exactly. Each type of steamer has a very large number of cages, which can be considered as infinite cages.

Whenever a customer wants to buy X steamed buns, the uncle who sells steamed buns will quickly select several cages of steamed buns, so that there are exactly X steamed buns in these cages. For example, there are 3 types of steamers, which can hold 3, 4 and 5 buns respectively. When a customer wants to buy 11 buns, the uncle will choose 2 cages of 3 plus 1 cage of 5 (may also choose 1 cage of 3 plus 2 cages of 4).

Of course, sometimes Uncle Baozi can't make up the quantity that customers want to buy anyway. For example, there are 3 types of steamers, which can hold 4, 5 and 6 buns respectively. And when the customer wanted to buy 7 buns, the uncle couldn't come out.

Xiao Ming wanted to know how many kinds of numbers there were that Uncle Baozi couldn't figure out.

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 representing the answer. If there are infinite numbers that cannot be made up, 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

Example explanation:
For example 1, the numbers that cannot be made up include: 1, 2, 3, 6, 7, 11.
For example 2, all odd numbers cannot be made up, so there are infinitely many.

Resource convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 1000ms
topic analysis
topic code



Question 9: Dividing Chocolate

Title Description
K children visited Xiaoming's house on Children's Day. Xiao Ming took out a collection of chocolates to entertain the children.
Xiao Ming has a total of N pieces of chocolate, of which the i-th piece is a rectangle composed of Hi x Wi squares.

为了公平起见,小明需要从这 N 块巧克力中切出K块巧克力分给小朋友们。切出的巧克力需要满足:

1. 形状是正方形,边长是整数  
2. 大小相同  

For example, a 6x5 chocolate can be cut into 6 2x2 chocolates or 2 3x3 chocolates.

Of course, the children all want the chocolate to be as large as possible. Can you help Xiao 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)
The input guarantees that each child will get at least one 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 convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 1000ms

topic analysis
topic code



Question 10: k times interval

Problem Description
Given a sequence of length N, A1, A2, … AN, if the sum of a continuous subsequence Ai, Ai+1, … Aj (i <= j) is a multiple of K, we call this The interval [i, j] is K times the 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-fold intervals.

For example,
enter:
5 2
1
2
3
4
5

The program should output:
6

Resource convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 2000ms
topic analysis
topic code



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326587349&siteId=291194637