[Detailed Explanation of the Real Questions of the Blue Bridge Cup Provincial Competition JavaB Group] Detailed Explanation of the Real Questions of the Fifth Blue Bridge Cup Provincial Competition (2014)

The first question: Wugong Cheats

Title Description
Xiao Ming went to X cave to explore and found a damaged martial arts cheat book (more than 2000 pages! Of course it is forged).
He noticed that the 10th and 11th pages of the book are on the same paper, but the 11th and 12th pages are not on the same paper.
Xiao Ming only wants to practice martial arts from page 81 to page 92 of the book, but doesn't want to bring the whole book. May I ask how many pieces of paper he must tear off at least to take away?
This is an integer, please submit the number through your browser, and do not fill in any extra content.
Answer analysis
click to view detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Martial Arts Cheats (2014))

Question 2: Cutting noodles

Topic description:
A high-gluten ramen noodles, cut in the middle, you can get 2 noodles.
If you fold it in half and cut it in the middle, you can get 3 noodles.
If you fold in half twice and cut in the middle, you can get 5 noodles.
So, how many noodles will you get if you fold in half 10 times and cut in the middle?

The answer is a whole number, please submit the answer through the browser. Don't fill in any redundant content.
Answer analysis
click to view detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Sliced ​​Noodles (2014))

Question 3: Guess the letter

Title description
Repeat the sequence consisting of 19 letters of abcd...s to splice 106 times to obtain a string of length 2014.

Next, delete the first letter (that is, the initial letter a), as well as the third and fifth letters in all odd positions.

The obtained new string then performs the action of deleting the odd-numbered letters. If this continues, there is only one letter left. Please write that letter.

The answer is a lowercase letter, please submit the answer via a browser. Don't fill in any redundant content.
Answer analysis
Welcome to follow the blogger, the solution to be updated

Fourth question: Dayan sequence

Title Description In
ancient Chinese documents, there was a record of "Dayan Sequence", which was mainly used to explain the derivative principles of Tai Chi in traditional Chinese culture.

Its first few items are: 0, 2, 4, 8, 12, 18, 24, 32, 40, 50...

The rule is: for even-numbered items, the square of the serial number is divided by 2; for odd-numbered items, the square of the serial number is divided by 1 and then divided by 2.

The following code prints the first 100 items of the Dayan sequence.

for(int i=1; i<100; i++)
{
    
    
    if(________________)  //填空
        System.out.println(i*i/2);
    else
        System.out.println((i*i-1)/2);
}

Please fill in the missing code in the underlined part. Submit the answer via the browser.
Note: Do not fill in the existing content of the title, and do not fill in any description or explanation text.

Answer Analysis
Click to view the detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Dayan Sequence (2014))

Question 5: Pi

Title Description In the
history of mathematical development, there have been many interesting and even legendary stories about the calculation of Pi. Many of these methods involve infinite series.

As shown in Figure 1.png, it is a method of calculating pi expressed in the form of continued fractions.

The following program implements this solution method. In fact, the convergence of the sequence is not sensitive to the initial value of x.

The result prints out the approximate value of pi (retain 4 digits after the decimal point, which does not necessarily match the true value of pi).

    double x = 111; 
    for(int n = 10000; n>=0; n--){
    
    
        int i = 2 * n + 1;
        x = 2 + (i*i / x);
    }
    
    System.out.println(String.format("%.4f", ______________));

p1
Answer analysis
click to view detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Pi (2014))

Question 6: Strange Fraction

Title description When
in elementary school, Xiao Ming often invented new algorithms by himself. Once, the teacher asked:

1/4 乘以 8/5

Xiao Ming actually spliced ​​the numerator together and the denominator together. The answer is: 18/45 (see the picture below) The

teacher just wanted to criticize him, so on another thought, this answer happened to be right, hell!

For the case where the numerator and denominator are both a single digit from 1 to 9, what other formulas can be calculated like this?

Please write down the number of all different calculations (including the examples in the question).

Obviously, after exchanging the numerator and denominator, for example: 4/1 multiplied by 5/8 is enough to meet the requirements, which counts as a different formula.

But for the same numerator and denominator, 2/2 multiplied by 3/3 are too many types to count!

Answer analysis
click to view detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Strange Fraction (2014))

Question 7: Poker sequence

Title description
AA 2 2 3 3 4 4, a total of 4 pairs of playing cards. Please line them up.

Requirements: There is 1 card between two Aces, 2 cards between two 2s, 3 cards between two 3s, and 4 cards between two 4s.

Please fill in the lowest lexicographic order among all the permutations that meet the requirements.

For example: 22AA3344 is lexicographically smaller than A2A23344. Of course, they are not the answer to the requirements. ·
Answer analysis
click to view detailed explanation ([Blue Bridge Cup JavaB Group Real Question Detailed Explanation] Poker Sequence (2014))

Question 8: Dividing candies

Title description
There are n children sitting in a circle. The teacher gave each child an even number of candies at random, and then played the following game:

Each child divided half of his candies to the child on his left.

After a round of sugar splitting, the child with an odd number of candies will be given an even number by the teacher.

Repeat this game until all children have the same number of candies.

Your task is to predict how many candies the teacher needs to reissue under the known initial candies.

【format requirement】

The program first reads an integer N (2<N<100), which represents the number of children.
Then there is a line of N even numbers separated by spaces (each even number is not greater than 1000, not less than 2), which
requires the program to output an integer, indicating the number of candies that the teacher needs to reissue.

For example: input
3
2 2 4 and the
program should output:
4

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.
Answer analysis
Welcome to follow the blogger, the solution to be updated

Question 9: Taking treasure from the underground palace

Title description
King X has a treasure trove of underground palaces. Is a matrix of nxm grids. Put a baby in each grid. Each baby is affixed with a value label.

The entrance to the underground palace is in the upper left corner, and the exit is in the lower right corner.

Xiao Ming was taken to the entrance of the underground palace, and the king asked him to walk to the right or down.

When walking through a grid, if the value of the treasure in that grid is greater than that of any treasure in Xiao Ming's hands, Xiao Ming can pick it up (of course, you don't need to take it).

When Xiao Ming walks to the exit, if the treasures in his hand happen to be k pieces, these treasures can be given to Xiao Ming.

Please help Xiaoming calculate how many different action plans he has to obtain these k treasures in a given situation.

【Data Format】

Enter 3 integers in a row, separated by spaces: nmk (1<=n,m<=50, 1<=k<=12)

Next, there are n rows of data, each row has m integers Ci (0<=Ci<=12) representing the value of the treasure on this grid

It is required to output an integer, which means that the number of action plans for exactly k babies is taken. This number may be very large, and output the result of modulo 1000000007.

For example, input:
2 2 2
1 2
2 1 The
program should output:
2

For another example, input:
2 3 2
1 2 3
2 1 5 The
program should output:
14

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.
Answer analysis
Welcome to follow the blogger, the solution to be updated

Question 10: Turning the coin over the matrix

Title description
Xiao Ming first put the coins into a matrix with n rows and m columns.

随后,小明对每一个硬币分别进行一次 Q 操作。

对第x行第y列的硬币进行 Q 操作的定义:将所有第 i*x 行,第 j*y 列的硬币进行翻转。

其中i和j为任意使操作可行的正整数,行号和列号都是从1开始。

当小明对所有硬币都进行了一次 Q 操作后,他发现了一个奇迹——所有硬币均为正面朝上。

小明想知道最开始有多少枚硬币是反面朝上的。于是,他向他的好朋友小M寻求帮助。

聪明的小M告诉小明,只需要对所有硬币再进行一次Q操作,即可恢复到最开始的状态。然而小明很懒,不愿意照做。于是小明希望你给出他更好的方法。帮他计算出答案。

[Data format] The
input data contains one line, two positive integers nm, and the meaning is shown in the title description.
Output a positive integer, indicating how many coins are facing up at the beginning.

【Sample input】
2 3

【Sample output】
1

[Data scale]
For 10% of data, n, m <= 10^3;
for 20% of data, n, m <= 10^7;
for 40% of data, n, m <= 10^15;
for For 100% data, n, m <= 10^1000 (10 to the 1000 power).

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.
Answer analysis
Welcome to follow the blogger, the solution to be updated

Guess you like

Origin blog.csdn.net/m0_46226318/article/details/113728447