2015 6th Java 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: Furbolg eats walnuts

Title description
There is a furbolg in the forest who loves walnuts. But it has a habit of dividing the walnuts it finds into two equal parts, eating one part, and keeping one. If it cannot be divided equally, the furbolg will throw away a walnut and divide it. Continue this process the next day until there is one walnut left, so throw it away. One day, the Furbolg found 1543 walnuts. May I ask how many walnuts it would lose in the process of eating these walnuts.
Topic analysis
topic codes


Question answer

3

Question 2: Galaxy Bomb

Title description
There are many X-star artificial "bombs" floating in the vast space of the X galaxy, which are used as road signs in the universe.
Each bomb can be set to explode in days.
For example, if the Alpha Bomb is placed on January 1, 2015 and the time is 15 days, it will explode on January 16, 2015.
There is a beta bomb, which was placed on November 9, 2014, with a timing of 1000 days. Please calculate the exact date when it exploded.

Please fill in the date, the format is yyyy-mm-dd, which is a 4-digit year, 2-digit month and 2-digit date. For example: 2015-02-19
please write in strict accordance with the format. No other words or symbols can appear.
Topic analysis
topic codes


Question answer

2017-08-05

Question 3: The number of nine is divided into three groups


The number from 1 to 9 in the title description can be composed of three 3-digit numbers, set as: A, B, C, and now the following relationship is required:
B = 2 * A
C = 3 * A

Please write down all possible answers to A. Use spaces to separate the numbers and arrange the numbers in ascending order.

Note: Only submit the value of A and output in strict accordance with the format requirements.
Topic analysis
topic codes


Question answer

192 219 273 327

Question 4: Length of cyclic section

Title description
Dividing two integers will sometimes produce cyclic decimals. The cyclic part is called: cyclic section.
For example, 11/13=6=>0.846153846153... Its loop section is [846153] and there are 6 digits in total.
The following method can find the length of the loop section.

Please read the code carefully and fill in the missing code in the underlined part.

    public static int f(int n, int m)
    {
    
    
        n = n % m;    
        Vector v = new Vector();
        
        for(;;)
        {
    
    
            v.add(n);
            n *= 10;
            n = n % m;
            if(n==0) return 0;
            if(v.indexOf(n)>=0)  _________________________________ ;  //填空
        }
    }

Topic analysis
topic codes


Question answer

return v.size() - v.indexOf(n);

Question 5: Printing diamonds

Title description
Give the side length of the rhombus and print a rhombus on the console.
In order to facilitate the comparison of spaces, we replace spaces with periods.
When the side length is 8, the rhombus is:

.......*
......*.*
.....*...*
....*.....*
...*.......*
..*.........*
.*...........*
*.............*
.*...........*
..*.........*
...*.......*
....*.....*
.....*...*
......*.*
.......*

The following program implements this function, but the idea is a bit strange.
Please analyze the code carefully and fill in the missing code in the underlined part.

public class A
{
    
    
    public static void f(int n)
    {
    
    
        String s = "*";
        for(int i=0; i<2*n-3; i++) s += ".";
        s += "*";
    
        String s1 = s + "\n";
        String s2 = "";
        
        for(int i=0; i<n-1; i++){
    
    
            //System.out.println("=>"+s);
            s = "." + _____________________________________ + "*";  //填空
            s1 = s + "\n" + s1;
            s2 += s + "\n";
        }
        System.out.println(s1+s2);        
    }
    
    public static void main(String[] args)
    {
    
    
        f(8);
    }
}

Topic analysis
topic codes


Question answer

s.substring(0, s.length()-3)

Sixth question: Addition to multiplication

Title description
We all know: 1+2+3+… + 49 = 1225
Now you are required to turn the two non-adjacent plus signs into multiplication signs, making the result 2015

For example:
1+2+3+…+10 11+12+…+27 28+29+…+49 = 2015
is the answer that meets the requirements.

Please look for another possible answer and submit the number to the left of the multiplication sign in the front position (for example, submit 10).

Note: What you need to submit is an integer, do not fill in any extra content.
Topic analysis
topic codes


Question answer

16

Question 7: Number of card types

Title description
Xiao Ming was hijacked to Casino X and forced to play cards with 3 other people.
A deck of playing cards (without the big and small trump cards, a total of 52), evenly distributed to 4 people, each with 13 cards.
At this time, a question suddenly appeared in Xiao Ming's mind:
If you don't consider suits, only points, and not the order of the cards you get, how many kinds of initial card combinations can you get in your hand?

Please fill in the whole number, do not fill in any extra content or explanatory text.
Topic analysis
topic codes


Question answer

3598180

Question 8: Moving distance

The title describes
that the buildings in the residential community of Planet X are all the same and arranged in a matrix pattern. The number of the buildings is 1, 2, 3...
When a row is full, the numbers are arranged in the opposite direction from the adjacent buildings in the next row.
For example: when the cell numbering width is 6, the starting situation is as follows:

1 2 3 4 5 6
12 11 10 9 8 7
13 14 15 …

Our problem is: Knowing two building numbers m and n, we need to find the shortest moving distance between them (can't move diagonally)

The input is 3 integers wmn, separated by spaces, all in the range of 1 to 10000
w is the width of the row number, m, n are the building numbers to be calculated.
It is required to output an integer, which represents the shortest moving distance between mn two buildings.

For example:
User input:
6 8 2
Then, the program should output:
4

Another example:
user input:
4 7 20
, the program should output:
5

Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <1000ms

Please output strictly according to the requirements, and don't superfluously print the extra content like: "Please input...".

All the codes are placed in the same source file. After the debugging is passed, copy and submit the source code.
Note: Do not use the package statement. Do not use the features of jdk1.7 and above.
Note: The name of the main class must be: Main, otherwise it will be processed as invalid code.
Topic analysis
topic codes


Question answer

在这里插入代码片

Question 9: Base dice

Title description The
gambling atm became obsessed with dice in his later years, that is, he puts the dice on top of the other, not crooked, and has to be square cylinders.
After long-term observation, ATM has discovered the mystery of stable dice: the faces of some numbers will repel each other!
Let's first standardize the dice: the opposite of 1 is 4, the opposite of 2 is 5, and the opposite of 3 is 6.
Assuming that there are m groups of mutual exclusion, the faces of the two numbers in each group are close to each other, and the dice cannot stand up stably. Atm wants to calculate how many different possible ways to base the dice.
The two ways to base the dice are the same, if and only if the directions of the corresponding numbers of the dice of the corresponding height in the two ways are the same.
Since there may be too many solutions, please output the result modulo 10^9 + 7.

Don’t underestimate the number of dice in ATM~

The
two integers nm
n in the first line of the "input format" represent the number of dice. The
next m lines have two integers ab in each line, indicating that a and b cannot be close together.

"Output Format" has
a number on a line, which means the answer modulo 10^9 + 7.

"Sample Input"
2 1
1 2

"Sample Output"
544

"Data Range"
For 30% data: n <= 5
For 60% data: n <= 100
For 100% data: 0 <n <= 10^9, m <= 36

Resource agreement:
Peak memory consumption (including virtual machines) <256M
CPU consumption <2000ms

Please output strictly according to the requirements, and don't superfluously print the extra content like: "Please input...".

All the codes are placed in the same source file. After the debugging is passed, copy and submit the source code.
Note: Do not use the package statement. Do not use the features of jdk1.7 and above.
Note: The name of the main class must be: Main, otherwise it will be processed as invalid code.
Topic analysis
topic codes



Question 10: Post-disaster reconstruction

The title describes that
there are N (<=50000) residential areas in Pear City, and M (<=200000) two-way roads are connected between the residential areas. Both of these settlements can be reached by two-way roads. This situation continued until recently, when a severe earthquake destroyed all M roads.
After the earthquake, Pear intends to repair some of these roads. Repairing the i-th road will take Pi's time. However, Pear does not intend to connect all the points, but chooses some specially labeled points to connect them.
Pear has Q (<=50000) queries. For each query, he will select all the points whose numbers are between [l,r] and whose number mod K = C, and repair some paths to make them connected. Since all road repairs can be started at the same time, the time to complete the repair depends on the road that takes the longest time, that is, the maximum value of Pi among the roads involved.

Can you help Pear calculate the minimum time required for each inquiry? The inquiry here is independent, that is, the repair plan in the previous inquiry was not put into action.

[Input format] The
three positive integers N, M, and Q in the first line have meanings as described in the title.
In the next M lines, each line has three positive integers Xi, Yi, Pi, indicating a two-way road connecting Xi and Yi, and it takes time for Pi to repair. There may be self-loops, and there may be heavy edges. 1<=Pi<=1000000.

In the next line Q, there are four positive integers Li, Ri, Ki, Ci in each line, indicating that the point in question this time is all points in the interval [Li, Ri] with numbers Mod Ki=Ci. Ensure that there are at least two points involved in the inquiry.

[Output format]
output Q lines, each line a positive integer represents the answer to the corresponding inquiry.

[Sample input]
7 10 4
1 3 10
2 6 9
4 1 5
3 7 4
3 6 9
1 5 8
2 7 4
3 2 10
1 7 6
7 6 9
1 7 1 0
1 7 3 1
2 5 1 0
3 7 2 1

[Sample output]
9
6
8
8

[Data range]
For 20% data, N, M, Q<=30
For 40% data, N, M, Q<=2000
For 100% data, N<=50000, M<=2*10^ 5,Q<=50000. Pi<=10^6. Li, Ri, Ki are all in the range of [1,N], and Ci is in the range of [0, corresponding to Ki).

Resource agreement:
peak memory consumption (including virtual machines) <256M
CPU consumption <5000ms

Please output strictly according to the requirements, and don't superfluously print the extra content like: "Please input...".

All the codes are placed in the same source file. After the debugging is passed, copy and submit the source code.
Note: Do not use the package statement. Do not use the features of jdk1.7 and above.
Note: The name of the main class must be: Main, otherwise it will be processed as invalid code.
Topic analysis
topic codes



Guess you like

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