2018 Ninth 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 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: Scores

Item 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 fraction.
Similar:
3/2
Of course, this just adds the first 2 items. The numerator and denominator are required to be coprime.

Note:
The scores that need to be submitted are already reduced scores, and no spaces can be included in any position in the middle.
Please do not fill in any extra text or symbols.
topic analysis
topic code



Question 2: Monday

Topic Description
How many Mondays were there in the 20th century (between January 1, 1901 and December 31, 2000)?
(don't tell me you don't know what day of the week it is)

Note: All you need to submit is an integer, do not fill in any extra content or explanatory text.
topic analysis
topic code



Question 3: Complex Powers

Problem Description
Let i be the imaginary unit. For any positive integer n, the real and imaginary parts of (2+3i)^n are integers.
What 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". Both the real part and the imaginary part are integers (which cannot be expressed in scientific notation), no spaces are added anywhere in between, 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



Question 4: Counting Grids

Title Description
As shown in Figure p1.png, there are an infinite number of 1x1 small squares on a two-dimensional plane.
We draw a circle with a radius of 50000 centered on a vertex of a small square.
Can you count how many complete small squares are in this circle?
Note: What needs to be submitted is an integer, do not fill in any redundant content.
insert image description here

topic analysis
topic code



Question 5: Printing Graphics

Title Description
The following program will draw a fractal graph (that is, a graph that is self-similar to the whole and the parts) on the console.

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

When n=1:
 O
ooo
 O

When n=2:
    O    
   ooo   
    O    
 ooo
ooooooooo
 ooo
    O    
   ooo   
    O    

When n=3:
             O             
            ooo            
             O             
          ooo          
         ooooooooo         
          ooo          
             O             
            ooo            
             O             
    ooo    
   ooo      ooo      ooo   
    ooo    
 ooooooooo
oooooooooooooooooooooooo
 ooooooooo
    ooo    
   ooo      ooo      ooo   
    ooo    
             O             
            ooo            
             O             
          ooo          
         ooooooooo         
          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 code



Question 6: Flight time

Title description
Xiao H went to the United States to participate in the International Blue Bridge Cup. Xiao H's girlfriend found out that Xiao H left at ten in the morning and arrived in the United States at twelve in the morning, so she sighed that "the plane is flying so fast now, and it can reach the United States in two hours".

Xiao h was very afraid of supersonic flight. After careful observation, it was found that the aircraft's take-off and landing times were in local time. Because there is a 12-hour time difference between Beijing and the eastern United States, the plane needs a total of 14 hours of flight time.

Soon after, Xiao H's girlfriend went to the Middle East to exchange. Xiao h did not know the time difference between the Middle East and Beijing. But Xiao H got the take-off and landing time for his girlfriend's round-trip flight. Xiao h wants to know what is the flight time of his girlfriend's flight.

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

【Input format】
Read data from standard input.

An input contains multiple sets of data.

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

Each set of data contains two rows, the first row is the take-off and landing time of the outgoing journey, and the second row is the take-off and landing time of the return journey.

The format of takeoff and landing times 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 the flight is at m1 at the local time h1 s1 seconds to take off,

The first format means landing at h2 hours m2 minutes s2 seconds local time on the current day

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

The third format means landing at h4 hours m4 minutes s4 seconds on the third day of local time.

For all times given in the form hⓂ️s in this problem, guaranteed ( 0<=h<=23, 0<=m,s<=59 ).

【Output format】
Output to standard output.

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

Note that when the time is a one-digit number, leading zeros are to be padded. 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)

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

topic analysis
topic code



Question 7: Three-Body Attack

Title Description
The Trisolarans will attack the Earth. In order to defend against the attack, the earthlings sent A × B × C warships to form a cube with A layer, B row and C column in space. Among them, the life value of the battleship in the jth row and the kth column of the i-th layer (denoted as battleship(i, j, k)) is d(i, j, k).

The Trisolarans will launch m rounds of "cube attacks" on Earth, each attack dealing the same amount of damage to all ships in a small cube. Specifically, the t-th round attack is described by 7 parameters lat, rat, lbt, rbt, lct, rct, ht;
all satisfy i ∈ [lat, rat], j ∈ [lbt, rbt], k ∈ [lct, rct ]'s ships (i, j, k) take damage from ht. If a ship's cumulative damage exceeds its defense, the ship will explode.

Earth Commander wants you to tell him what round of attack the first warship to explode 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 ((i − 1)×B + (j − 1)) × C + (k − 1)+1 numbers are d(i, j, k);
in lines 3 to m + 2, line (t − 2) contains 7 positive integers lat, rat, lbt, rbt, lct, rct , ht.

【Output format】
Output to standard output.
Output after which round of attack the ship that exploded first exploded. Guaranteed to exist 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

[Example explanation]
After the 2nd round of attack, the battleship (1,1,1) suffered a total of 2 points of damage, which exceeded its defense and caused an explosion.

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

topic analysis
topic code



Question 8: Global Warming

Title Description
You have a NxN pixel photo of a certain sea area, "." means ocean, "#" means land, as follows:


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

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

Due to rising sea levels caused by global warming, scientists predict that a pixel of the edge of the island will be submerged by sea water in the next few decades. Specifically, if a land pixel is adjacent to an ocean (there are oceans in four adjacent pixels up, down, left, and right), it will be submerged.

For example, the sea area in the picture above will look like this in the future:





…#…

Please count: According to scientists' predictions, 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 photo guarantees that the pixels in row 1, column 1, row N, and column N are all oceans.

[Output format]
An integer represents the answer.

【Input example】
7

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

【Example of output】
1

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



Question 9: Multiple Problems

Topic description
As we all know, Xiao onion is good at calculation, especially good at calculating whether a number is a multiple of another number. But shallots are only good at two numbers, and when there are many numbers, they will be more distressed. Now the onion has given you n numbers, and 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 guarantees that there must be a solution.

【Input format】
Read data from standard input.
The first line contains 2 positive integers n, K.
The second line contains n positive integers representing the given n numbers.

【Output format】
Output to standard output.
One line of output is an integer representing the desired sum.

【Sample input】
4 3
1 2 3 4

[Sample output]
9

[Example explanation]
Select 2, 3, and 4.

[Data convention]
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% of the data, 1 <= n <= 10^5, 1 <= K <= 10^3, and none of the given n numbers exceed 10^8.

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

topic analysis
topic code



Question 10: Billing Issues

Topic description
It is not uncommon for several people to go out to dinner together. But at checkout, there are often disputes.

Now there are n people going out to eat, and they spend a total of S dollars. The i-th person brought ai yuan. Fortunately, the sum of the money everyone brought was enough to pay the bill, but now the question arises: how much will each one pay?

To be fair, we want the standard deviation of each person's payment to be the smallest in the end, given that the total payment is exactly S. Here we agree that the amount of money paid by each person can be any non-negative real number, that is, it can not be an integer multiple of 1 cent. You need to output what is the smallest standard deviation.

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

【Input format】
Read data from standard input.
The first line contains two integers n, 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.
It is guaranteed that adding or subtracting 10^−9 to the correct answer will not cause the rounded result to change.

【Sample input】
5 2333
666 666 666 666 666

[Sample output]
0.0000

[Example explanation]
Everyone contributes 2333/5 yuan, and the standard deviation is 0.

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

[Sample output]
0.7928

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

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.
Don't use the package statement. Do not use features of jdk1.7 and above.
The name of the main class must be: Main, otherwise it will be processed as invalid code.
insert image description here

topic analysis
topic code



Guess you like

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