2018 9th 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: Score

Title description
1/1 + 1/2 + 1/4 + 1/8 + 1/16 + …
Each item is half of the previous item. If there are 20 items in total,
what is the sum and the result is expressed as a score.
Similar:
3/2
Of course, this is just adding the first 2 items. The numerator and denominator must be relatively prime.

Note:
The scores that need to be submitted are the scores that have been subscribed, and no spaces are allowed in the middle.
Please do not fill in any extra words or symbols.
Topic analysis
topic codes



Question 2: Monday

Title Description In the
entire 20th century (between January 1, 1901 and December 31, 2000), how many Mondays were there?
(Don't tell me you don't know what day it is today)

Note: What needs to be submitted is only an integer, do not fill in any extra content or explanatory text.
Topic analysis
topic codes



The third question: complex number power

Title description
Let i be the imaginary unit. For any positive integer n, the real and imaginary parts of (2+3i)^n are both integers.
How much is (2+3i)^123456 equal to? That is (2+3i) to the power of 123456. This number is very large and requires accurate representation.

The answer is written in the form of "real part ± imaginary part i". The real and imaginary parts are both integers (cannot be expressed in scientific notation), no spaces are added anywhere in the middle, and no positive sign is added before the real part is positive. (2+3i)^2 is written as: -5+12i,
(2+3i)^5 is written as: 122-597i
question analysis
question code



Fourth question: Counting squares

Title description
As shown in figure p1.png, there are countless 1x1 small squares on the two-dimensional plane.
We draw a circle with a radius of 50000 with a vertex of a small square as the center.
Can you calculate how many complete small squares are in this circle?
Note: What needs to be submitted is an integer, do not fill in any extra content.
Insert picture description here

Topic analysis
topic codes



Question 5: Print graphics

Title description The
following program will draw a fractal graph (i.e. the overall and partial self-similar graphs) on the console.

When n=1,2,3, the output is as follows:
Please analyze the program carefully and fill in the missing codes in the underlined part.

n = 1时: 
 o 
ooo 
 o 

n = 2时: 
    o     
   ooo    
    o     
 ooo 
nowhere 
 ooo 
    o     
   ooo    
    o     

n = 3时: 
             o              
            ooo             
             o              
          ooo           
         nowhere          
          ooo           
             o              
            ooo             
             o              
    ooo     
   ooo ooo ooo    
    ooo    
 o  o  o  o  o  o  o  o  o 
wipers 
 nowhere 
    ooo     
   ooo ooo ooo    
    ooo     
             o              
            ooo             
             o              
          ooo           
         nowhere          
          ooo           
             o              
            ooo             
             o             
            
public class Main
{
    
    
    static void show(byte[][] buf){
    
    
        for(int i=0; i<buf.length; i++){
    
    
            for(int j=0; j<buf[i].length; j++){
    
    
                System.out.print(buf[i][j]==0? ' ' : 'o');
            }
            System.out.println();
        }
    }
    
    static void draw(byte[][] buf, int x, int y, int size){
    
    
        if(size==1){
    
    
            buf[y][x] = 1;
            return;
        }
        
        int n = ________________________ ;  // 填空
        draw(buf, x, y, n);
        draw(buf, x-n, y ,n);
        draw(buf, x+n, y ,n);
        draw(buf, x, y-n ,n);
        draw(buf, x, y+n ,n);
    }
    
    public static void main(String[] args){
    
    
        final int N = 3;
        int t = 1;
        for(int i=0; i<N; i++) t *= 3;
        
        byte[][] buf = new byte[t][t];
        draw(buf, t/2, t/2, t);
        show(buf);
    }
}

Topic analysis
topic codes



Question 6: Flight time

Title description
Xiao h went to the United States to participate in the Blue Bridge International Cup. Xiao H’s girlfriend discovered that Xiao H departed at 10 am and arrived in the United States at 12 in the morning, so she sighed that "the plane is flying so fast now, and it will take two hours to reach the United States."

Xiao H is very terrified of supersonic flight. After careful observation, it was found that the take-off and landing times of the aircraft were all local time. As there is a 12-hour time difference between Beijing and the eastern United States, the aircraft needs a total of 14 hours of flight time.

Soon H's girlfriend went to the Middle East to exchange. Little h does not know the time difference between the Middle East and Beijing. But Xiao H got the takeoff and landing time of his girlfriend's round-trip flight. Little h wants to know the flight time of his girlfriend's flight.

[Problem description]
For a flight that may cross time zones, a given round-trip take-off and landing time. Assuming that the flight time of the plane is the same, find the flight time of the plane.

[Input format]
Read data from standard input.

One input contains multiple sets of data.

The first line of input is a positive integer T, which represents the number of input data groups.

Each group of data contains two lines, the first line is the take-off and landing time of the outbound journey, and the second line is the take-off and landing time of the return journey.

The format of take-off and landing time is as follows

h1:m1:s1 h2:m2:s2
or
h1:m1:s1 h3:m3:s3 (+1)
or
h1:m1:s1 h4:m4:s4 (+2)
means that the flight is at h1, m1, local time take off in 1 second,

The first format means landing at h2, m2 minutes and s2 seconds on the day of local time

The second format means landing at h3 hours, m3 minutes, and s3 seconds on the next day of local time.

The third format means that it will land at h4, m4:s4 on the third day of local time.

For all the time given in the form of hⓂ️s in this question, it is guaranteed (0<=h<=23, 0<=m,s<=59 ).

[Output format]
Output to standard output.

For each set of data, output a line of time hh:mm:ss, which means that the flight time is hh hours mm minutes ss seconds.

Note that when the time is one digit, the leading zeros should be filled. For example, three hours, four minutes and five seconds should be written as 03:04:05.

[Sample input]
3
17:48:19
21:57:24 11:05:18
15:14:23 17:21:07 00:31:46 (+1)
23:02:41 16:13:20 (+1)
10:19:19 20:41:24 22:19:04 16:41:09
(+1)

[Sample output]
04:09:05
12:10:39
14:22:05

[Restrictions and Agreements]
Ensure that the input time is legal and the flight time does not exceed 24 hours.

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

Topic analysis
topic codes



Question 7: Three-body attack

Title Description The
Trisolarans will launch an attack on the earth. In order to resist the attack, the Earthlings sent A × B × C warships, arranged in space into a cube with A layer, B row and C column. Among them, the life value of the battleship (denoted as battleship (i, j, k)) in the jth row and kth column of the i-th layer is d(i, j, k).

The Trisolarans will launch m rounds of "cube attacks" on the earth. Each attack will cause the same damage to all warships in a small cube. Specifically, the t-th round of attack is described by 7 parameters lat, rat, lbt, rbt, lct, rct, ht;
all satisfying i ∈ [lat, rat], j ∈ [lbt, rbt], k ∈ [lct, rct ]’S battleship (i, j, k) will be damaged by ht. If the total damage received by a battleship exceeds its defense power, the battleship will explode.

The Earth Commander wants you to tell him in which round of attack the first exploded battleship exploded.

[Input format]
Read data from standard input.
The first row contains 4 positive integers A, B, C, m; the
second row contains A × B × C integers, where the th ((i − 1)×B + (j − 1)) × C + (k − 1)+1 number is d(i, j, k); in
the 3rd to m + 2th row, the (t − 2)th row contains 7 positive integers lat, rat, lbt, rbt, lct, rct , ht.

[Output format]
Output to standard output.
After which round of attack did the first exploded battleship exploded. It is guaranteed that there must be such a warship.

[Sample input]
2 2 2 3
1 1 1 1 1 1 1 1
1 2 1 2 1 1 1
1 1 1 2 1 2 1
1 1 1 1 1 1 2

【Sample output】
2

[Sample explanation]
After the second round of attack, the battleship (1,1,1) received a total of 2 points of damage, exceeding its defense power and causing an explosion.

[Data Agreement]
For 10% of the data, B = C = 1;
for 20% of the data, C = 1;
for 40% of the data, A × B × C, m ≤ 10,000;
for 70% of the data, A, B, C ≤ 200;
for all data, A × B × C ≤ 10^6, m ≤ 10^6, 0 ≤ d(i, j, k), ht ≤ 10^9.

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

Topic analysis
topic codes



Question 8: Global Warming

Title description
You have a picture of a certain sea area with NxN pixels, "." means ocean, "#" means land, as shown below:


.##…
.##…
…##.
…####.
…###.

Among them, a piece of land connected in four directions "up, down, left, and right" forms an island. For example, there are 2 islands in the picture above.

As global warming has caused the sea to rise, scientists predict that in the next few decades, a pixel area on the edge of the island will be submerged by sea water. Specifically, if a land pixel is adjacent to the ocean (there is an ocean among the four adjacent pixels up, down, left, and right), it will be submerged.

For example, the sea area in the above picture will become as follows in the future:





…#…

Please calculate: According to the prediction of scientists, how many islands in the photo will be completely submerged.

[Input format] The
first line contains an integer N. (1 <= N <= 1000) The
following N rows and N columns represent a sea area photo.

The picture guarantees that the pixels in the first row, the first column, the Nth row, and the Nth column are all oceans.

[Output format]
An integer represents the answer.

[Input example]
7

.##…
.##…
…##.
…####.
…###.

[Sample output]
1

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.
Do not use the package statement. Do not use the features of jdk1.7 and above.
The name of the main class must be: Main, otherwise it will be treated as an invalid code.
Topic analysis
topic codes



Question 9: Multiples

Topic description
As everyone knows, Xiao Cong is good at calculation, especially good at calculating whether one number is a multiple of another. But Scallion is only good at two numbers, and it will be more distressed when there are many numbers. Now Scallion has given you n numbers. I hope you can find three numbers from these n numbers so that the sum of these three numbers is a multiple of K, and this sum is the largest. The data guarantee must have a solution.

[Input format]
Read data from standard input.
The first line contains 2 positive integers n, K.
In the second line, n positive integers represent the given n numbers.

[Output format]
Output to standard output.
Output an integer on a line to represent the sum.

【Sample input】
4 3
1 2 3 4

[Sample output]
9

[Sample explanation]
Choose 2, 3, 4.

[Data Agreement]
For 30% of the data, n <= 100.
For 60% of the data, n <= 1000.
For the other 20% of the data, K <= 10.
For 100% data, 1 <= n <= 10^5, 1 <= K <= 10^3, and the given n numbers do not exceed 10^8.

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

Topic analysis
topic codes



Question 10: Payment problems

Title description It
is common for several people to go out to eat together. But during the checkout, there are often some disputes.

Now there are n people eating out, and they have consumed S yuan in total. Among them, the i-th person brought ai yuan. Fortunately, the total amount of money everyone brings is enough to pay the bill, but now the question is: how much does each person pay?

For the sake of fairness, we hope that on the premise that the total payment amount is exactly S, the standard deviation of the final payment for everyone is the smallest. Here we agree that the amount of money paid by each person can be any non-negative real number, that is, it may not be an integer multiple of 1 cent. You need to output the smallest standard deviation.

Introduction to standard deviation: Standard deviation is the squared mean of the difference between multiple numbers and their averages. It is generally used to describe the "how much deviation" between these numbers. Formally speaking, suppose the i-th person pays bi yuan, then the standard deviation is: [see p1.png]

[Input format]
Read data from standard input.
The first line contains two integers n and S; the
second line contains n non-negative integers a1, …, an.

[Output format]
Output to standard output.
Output the smallest standard deviation, rounded to 4 decimal places.
Ensure that the correct answer will not change the rounded result after adding or subtracting 10^−9.

[Sample input]
5 2333
666 666 666 666 666

【Sample output】
0.0000

[Sample explanation]
Everyone pays 2333/5 yuan, with a standard deviation of 0.

Another example:
[Sample input]
10 30
2 1 4 7 4 8 3 6 4 7

[Sample output]
0.7928

[Data Agreement]
For 10% of the data, all ai are equal;
for 30% of the data, all non-zero ai are equal;
for 60% of the data, n ≤ 1000;
for 80% of the data, n ≤ 10^5;
for All data, n ≤ 5 × 10^5, 0 ≤ ai ≤ 10^9.

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.
Do not use the package statement. Do not use the features of jdk1.7 and above.
The name of the main class must be: Main, otherwise it will be treated as an invalid code.
Insert picture description here

Topic analysis
topic codes



Guess you like

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