The 5th Java Group B Blue Bridge Cup Provincial Competition in 2014

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: Martial Arts Cheats

Title description
Xiao Ming went to X cave to explore and found a damaged martial arts book (more than 2000 pages! Of course it was fake). He noticed: Pages 10 and 11 of the book were on the same sheet, but pages 11 and 12 were not on the same sheet.
Xiao Ming just wanted to practice the martial arts on pages 81 to 92 of the book, and he didn't want to bring the whole book with him. May I ask how many pieces of paper he should tear off and take away?
This is an integer, please submit the number through your browser without any extras.
topic analysis
topic code



Question 2: Cut noodles

Item description
A high-gluten ramen, cut a knife in the middle, you can get 2 noodles.
If you fold it in half first and cut a knife in the middle, you can get 3 noodles.
If you fold it twice in a row and cut a knife in the middle, you can get 5 noodles.
Then, if you fold it in half 10 times in a row and cut a knife in the middle, how many noodles will you get?
The answer is an integer, please submit the answer through your browser. Do not fill in any superfluous content.
topic analysis
topic code



Question 3: Guess the letters

Title description
: Repeat the splicing of the 19-letter sequence of abcd...s 106 times to obtain a string of length 2014. Next, delete the first letter (that is, the letter a at the beginning), and the third, fifth, etc. letters in all odd positions. The obtained new string performs the action of deleting the letters in odd positions. And so on, there is only one letter left, please write that letter.
The answer is a lowercase letter, please submit the answer through your browser. Do not fill in any superfluous content.
topic analysis
topic code



Question 4: Dayan Sequence

Title Description
In ancient Chinese literature, the "Dayan Sequence" was recorded, which was mainly used to explain the principle 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 items, the square of the serial number is divided by 2; for odd items, the square of the serial number minus 1 Then divide by 2.
The following code prints the first 100 entries of the Dayan series.

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

topic analysis
topic code



Question 5: Pi Ratio

Topic Description
In the history of mathematics development, the calculation of pi has many interesting and even legendary stories. Many of these methods involve infinite series.
As shown in Figure 1.png, it is a method for calculating pi expressed in the form of a continuous fraction.
The following program implements this solution method. Actually the convergence of the sequence is not sensitive to the initial value of x.
The result prints the approximate value of pi (retains 4 decimal places, and 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", ______________));

insert image description here

topic analysis
topic code



Question 6: Strange Fractions

Topic description
When he was in elementary school, Xiao Ming often invented new algorithms by himself. Once, the teacher asked the question:
1/4 times 8/5
Xiaoming actually spliced ​​the numerator and denominator together, the answer was: 18/45 (see Figure 1.png) The
teacher just wanted to criticize him, but then he read one Think, this answer happens to be right, what the hell!
For the case where both the numerator and the denominator are one digit from 1 to 9, what other formulas can be calculated in this way?
Please write down the number of all the different equations (including the examples in the question).
Obviously, after exchanging the numerator and denominator, for example: 4/1 times 5/8 is satisfactory, which counts as a different formula.
But with the same numerator and denominator, 2/2 times 3/3 are too many types to count!
insert image description here

Note: The answer is an integer (it must be an even number considering symmetry). Please submit via browser. Don't write superfluous content.
topic analysis
topic code



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: 1 card between two aces, 2 cards between two 2s, 3 cards between two 3s, and 4 cards between two 4s. Please fill in all the permutations that meet the requirements, the one with the smallest lexicographical order.
For example: 22AA3344 is lexicographically smaller than A2A23344. Of course, none of them are answers that suffice.
Please submit answers through your browser. "A" must not be replaced with a lowercase letter a, and "1" should not be used instead. There must be no spaces between characters.
topic analysis
topic code



Question 8: Divide Candy

Problem Description
There are n children sitting in a circle. The teacher randomly distributes an even number of candies to each child, and then plays the following game:
each child gives half of his candy to the child on the left.
After a round of candy distribution, the child with an odd number of candies will be supplied with 1 candy by the teacher, thus becoming an even number.
Repeat the game until all children have the same number of candies.
Your task is to predict how many replacement candies the teacher will need to hand out given the known initial candy situation.
[Format requirements]
The program first reads an integer N (2<N<100), which represents the number of children.
Next 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 the
program should output:
4

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

topic analysis
topic code



Question 9: Treasure from the Underground Palace

Title Description
King X has an underground treasury. is a matrix of nxm lattices. Put one treasure in each cell. Each baby has a value sticker attached. 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 only to the right or down. When walking through a certain grid, if the value of the treasure in that grid is greater than that of any treasure in Xiao Ming's hand, Xiao Ming can pick it up (of course, he can also not take it). When Xiaoming walks to the exit, if the treasures in his hand are exactly k, these treasures can be given to Xiaoming.
Please help Xiao Ming calculate how many different action plans he has to obtain these k treasures in a given situation.
[Data format]
Enter a line of 3 integers, separated by spaces: nmk (1<=n,m<=50, 1<=k<=12)
Next, there are n lines of data, each line has m integers Ci (0 <=Ci<=12) represents the value of the treasure on this grid. It is
required to output an integer, indicating the number of action plans to take exactly k treasures. The number can be large, print it 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 convention:
peak memory consumption (including virtual machine) < 256M
CPU consumption < 2000ms
topic analysis
topic code



Question 10: Matrix flipping coins

Topic description
Xiao Ming first arranged the coins into a matrix with n rows and m columns. Subsequently, Xiao Ming performs a Q operation on each coin. Definition of Q-operation on coins in row x, column y: flip all coins in row i x, column j y. where i and j are any positive integers that make the operation feasible, and both row and column numbers start at 1. When Xiao Ming made a Q operation on all the coins, he found a miracle - all the coins were heads up. Xiao Ming wants to know how many coins came up tails in the beginning. So he asked his good friend Xiao M for help. The clever little M told Xiao Ming that he only needed to perform another Q operation on all coins to restore to the original state. However, Xiao Ming was lazy and did not want to do it. So Xiao Ming wants you to give him a better way. Help him figure out the answer.

[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 initially came up tails.

【Sample input】
2 3

[Sample output]
1

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

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



Guess you like

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