2015 6th Java Group A Blue Bridge Cup Provincial Championship

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: The furbolg eats walnuts

Title description
There is a furbolg in the forest who likes to eat walnuts. But it has a habit of dividing the walnuts it finds into two equal parts, eating one and keeping one. If it cannot be divided equally, the furbolg will drop a walnut and divide it. Continue this process the next day until there is one walnut left at the end, just throw it away. One day, the furbolg found 1543 walnuts. Excuse me, how many walnuts will it lose in the process of eating these walnuts?
topic analysis
topic code


question answer

3

Question 2: Galaxy Bomb

Title Description
There are many X-star man-made "bombs" floating in the vast expanse of galaxy X, which are used as road signs in the universe.
Each bomb can be set to detonate after a set number of days.
For example: if the Alpha bomb was placed on January 1, 2015, and the timing was 15 days, it would explode on January 16, 2015.
There is a beta bomb, placed on November 9, 2014, with a timing of 1000 days, please calculate the exact date it exploded.

Please fill in the date in the format of yyyy-mm-dd, that is, 4 digits for the year, 2 digits for the month, and 2 digits for the date. For example: 2015-02-19
Please write in strict accordance with the format. No other words or symbols may appear.
topic analysis
topic code


question answer

2017-08-05

Question 3: Divide nine numbers into three groups

The question describes
that the numbers from 1 to 9 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 the possible answers to A, separating the numbers with spaces, in ascending order.

Note: Only submit the value of A, and output it in strict accordance with the format requirements.
topic analysis
topic code


question answer

192 219 273 327

Question 4: Cycle Section Length

Topic description
When dividing two integers, sometimes a recurring decimal is generated. The recurring part is called: recurring section.
For example, 11/13=6=>0.846153846153… The loop section is [846153] with a total of 6 bits.
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 code


question answer

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

Question 5: Printing a Rhombus

Problem Description
Given the side lengths of a rhombus, print a rhombus on the console.
To facilitate comparison of spaces, we replace spaces with periods.
When the side length is 8, the rhombus is:

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

The following program implements this functionality, but the idea is a bit odd.
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 code


question answer

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

Question 6: Addition to Multiplication

Problem Description
We all know: 1+2+3+ … + 49 = 1225
Now you are asked to turn two of the non-adjacent plus signs into multiplication signs so that the result is 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 first multiplication sign (for the example, submit 10).

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


question answer

16

Question 7: Number of Card Types

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

Please fill in the whole number without any superfluous content or explanatory text.
topic analysis
topic code


question answer

3598180

Question 8: Movement Distance

Title Description
The buildings in the residential community of Planet X are all the same and arranged in a matrix style. The number of its 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 row number 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 row number width, m, n are the building numbers to be calculated.
It is required to output an integer representing the shortest moving distance between the two floors of mn.

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 convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 1000ms

Please output strictly according to the requirements, and do not superficially print superfluous content like: "Please enter...".

All code is placed in the same source file, after debugging, copy and submit the source code.
Note: Do not use the package statement. Do not use 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 code


question answer

在这里插入代码片

Question 9: Base the dice

Title description
The gambling saint atm was obsessed with stacking dice in his later years, that is, stacking the dice one on top of the other.
After a long period of observation, atm discovered the mystery of stable dice: some numbers face each other repel each other!
Let's standardize the dice first: the opposite of a 1 is a 4, the opposite of a 2 is a 5, and the opposite of a 3 is a 6.
Assuming that there are m groups of mutually exclusive phenomena, the faces of the two numbers in each group are close to each other, and the dice cannot be stably stacked. atm wants to count how many different possible ways to roll the dice.
The two ways of laying dice are the same if and only if the corresponding numbers of the dice of corresponding heights in both ways are facing the same.
Since the number of solutions may be too many, please output the result modulo 10^9 + 7.

Don't underestimate the number of dice at ATM~

"Input format"
The first line of two integers nm
n represents the number of dice
, the next m lines, each line of two integers ab, indicating that a and b cannot be closely together.

"Output format" is
one number per line, indicating the result of the answer modulo 10^9 + 7.

"Sample Input"
2 1
1 2

"Sample output"
544

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

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

Please output strictly according to the requirements, and do not superficially print superfluous content like: "Please enter...".

All code is placed in the same source file, after debugging, copy and submit the source code.
Note: Do not use the package statement. Do not use 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 code



Question 10: Post-disaster reconstruction

Title Description
Pear City has a total of N (<=50000) settlements, and there are M (<=200000) two-way roads connecting the settlements. These settlements can be reached by two-way roads. This continued until recently, when a severe earthquake destroyed all M roads.
After the earthquake, Pear intends to repair some of these roads, and it will take Pi's time to repair the i-th road. However, Pear does not intend to connect all the points, but selects some points with special labels to connect them.
Pear has Q (<=50000) queries. For each query, he will select all points numbered between [l,r] and number mod K = C, and repair some roads to connect them. Since the repair of all roads 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 figure out the minimum amount of time each query will take? The inquiry here is independent, that is, the repair plan in the previous inquiry has not been put into action.

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

Next line Q, each line contains four positive integers Li, Ri, Ki, and Ci, indicating that the point to be queried this time is all points with Mod Ki=Ci in the [Li, Ri] interval. Make sure there are at least two points participating in the inquiry.

[Output format]
Output Q lines, each line is a positive integer representing the answer to the corresponding query.

【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

【Example output】
9
6
8
8

[Data range]
For 20% of the data, N,M,Q<=30
for 40% of the data, N,M,Q<=2000
for 100% of the 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 the query Ki).

Resource convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 5000ms

Please output strictly according to the requirements, and do not superficially print superfluous content like: "Please enter...".

All code is placed in the same source file, after debugging, copy and submit the source code.
Note: Do not use the package statement. Do not use 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 code



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324783483&siteId=291194637