2016 7th Java Group A Blue Bridge Cup Provincial Tournament 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: Number of briquettes

Title description
There is a pile of briquettes in a triangular pyramid shape. Specifically:
1 in the first layer,
3 in the second layer (arranged in a triangle),
6 in the third layer (arranged in a triangle),
10 in the fourth layer (arranged in a triangle),
...
if there are 100 layers in total, there are How many briquettes?

Please fill in the number representing the total number of briquettes.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Topic analysis
topic codes



Question 2: Birthday candles

Description of the title
A certain person has held a birthday party every year since a certain year, and every time he blows out the same number of candles as his age.

Counting now, he blew out a total of 236 candles.

Excuse me, at what age did he start his birthday party?

Please fill in the age when he started the birthday party.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Topic analysis
topic codes



Question 3: Build blocks

Title description
Xiao Ming likes to build digital blocks recently.
There are 10 blocks in total, and each block has a number, 0-9.


Building block rules: Put each block on top of the other two blocks, and it must be smaller than the two blocks below.
Finally, a 4-layer pyramid is built, and all the blocks must be used.

The following are two qualified methods:

   0
  1 2
 3 4 5
6 7 8 9

   0
  3 1
 7 5 2
9 8 6 4    

Could you please calculate how many kinds of such methods are there?

Please fill in the number indicating the total number.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Topic analysis
topic codes



Fourth question: sub-groups

The topic describes
9 athletes participating in the competition, and they need to be divided into 3 groups for preliminaries.
What are the grouping schemes?

We mark athletes as A, B, C,... I.
The following program lists all the grouping methods.

Normal output of the program is:
the ABC the DEF GHI
the ABC of DEG FHI
the ABC DEH the FGI
the ABC the DEI FGH
the ABC the DFG EHI
the ABC the DFH EGI
the ABC DFI EGH
the ABC the DGH the EFI
the ABC the DGI the EFH
the ABC DHI EFG
the ABC EFG DHI
the ABC the EFH the DGI
the ABC the EFI the DGH
the ABC EGH DFI
the ABC EGI the DFH
ABC EHI DFG
ABC FGH DEI
ABC FGI DEH
ABC FHI the DEG
ABC GHI DEF
ABD CEF GHI
ABD CEG FHI
ABD CEH FGI
ABD CEI FGH
ABD CFG EHI
ABD CFH EGI
ABD CFI EGH
ABD CGH EFI
ABD CGI EFH
ABD CHI EFG
ABD EFG CHI
… (Omitted below, 560 lines in total).

public class A
{
    
    
    public static String remain(int[] a)
    {
    
    
        String s = "";
        for(int i=0; i<a.length; i++){
    
    
            if(a[i] == 0) s += (char)(i+'A');
        }    
        return s;
    }
    
    public static void f(String s, int[] a)
    {
    
    
        for(int i=0; i<a.length; i++){
    
    
            if(a[i]==1) continue;
            a[i] = 1;
            for(int j=i+1; j<a.length; j++){
    
    
                if(a[j]==1) continue;
                a[j]=1;
                for(int k=j+1; k<a.length; k++){
    
    
                    if(a[k]==1) continue;
                    a[k]=1;
                    System.out.println(__________________________________);  //填空位置
                    a[k]=0;
                }
                a[j]=0;
            }
            a[i] = 0;
        }
    }
    
    public static void main(String[] args)
    {
    
    
        int[] a = new int[9];        
        a[0] = 1;
        
        for(int b=1; b<a.length; b++){
    
    
            a[b] = 1;
            for(int c=b+1; c<a.length; c++){
    
    
                a[c] = 1;
                String s = "A" + (char)(b+'A') + (char)(c+'A');
                f(s,a);
                a[c] = 0;
            }
            a[b] = 0;
        }
    }
}

Read the code carefully and fill in the missing content in the underlined part.
Note: Do not fill in any existing content or explanatory text.
Topic analysis
topic codes



Question 5: Lottery

The title describes that
Planet X will send a 5-member observation group to Star W.
Among them:
Country A can send up to 4 people.
Country B can send up to 2 people.
Country C can send up to 2 people.

So how many different combinations of countries will the observation mission sent to W Star in the end?

The following procedure solves this problem.
The array a[] is the largest number of places that each country can send.
The program execution result is:
DEFFF
CEFFF
CDFFF
CDEFF
CCFFF
CCEFF
CCDFF
CCDEF
BEFFF
BDFFF
BDEFF
BCFFF
BCEFF
BCDFF
BCDEF

(Omitted below, a total of 101 lines)

public class A
{
    
    
    public static void f(int[] a, int k, int n, String s)
    {
    
    
        if(k==a.length){
    
     
            if(n==0) System.out.println(s);
            return;
        }
        
        String s2 = s;
        for(int i=0; i<=a[k]; i++){
    
    
            _____________________________;   //填空位置
            s2 += (char)(k+'A');
        }
    }
    
    public static void main(String[] args)
    {
    
    
        int[] a = {
    
    4,2,2,1,1,3};
        
        f(a,0,5,"");
    }
}

Topic analysis
topic codes



Sixth question: Winter homework

Topic description
Now the math problems in elementary school are not so fun.
Take a look at this winter homework:

□ + □ = □
□ - □ = □
□ × □ = □
□ ÷ □ = □

(If it is not displayed, please refer to [Figure 1.jpg])

Each square represents a certain number from 1 to 13, but cannot be repeated.
For example:
6 + 7 = 13
9-8 = 1
3 * 4 = 12
10/2 = 5

And:
7 + 6 = 13
9-8 = 1
3 * 4 = 12
10/2 = 5

Even two solutions. (Addition and multiplication are different schemes after the commutative law)

How many solutions have you found?

Please fill in an integer representing the number of plans.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Insert picture description here

Topic analysis
topic codes



Question 7: Cut stamps

Title description
As shown in [Picture 1.jpg], there are 12 stamps with 12 zodiac signs connected together.
Now you have to cut out 5 sheets from it, the requirement must be connected.
(Just connecting one corner does not count as connected) For
example, in [Picture 2.jpg], [Picture 3.jpg], the part shown in pink is a qualified cut.

Please calculate how many different clipping methods there are.

Please fill in an integer representing the number of plans.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Insert picture description here
Insert picture description here
Insert picture description here

Topic analysis
topic codes



Question 8: The game of taking the ball

Title description
Two people play a game of fetching the ball.
There are a total of N balls, and each person takes turns to take the ball, and each time can take any number in the set {n1, n2, n3}.
If the ball cannot be taken, the game is over.
At this time, the party holding an odd number of balls wins.
If both are odd, it is a tie.

Assuming that both sides use the smartest method, can the
first player win?
Try programming to solve this problem.

Input format:
3 positive integers n1 n2 n3 in the first line, separated by spaces, indicating the number that can be taken at a time (0<n1, n2, n3<100),
5 positive integers x1 x2… x5 in the second line, separated by spaces, indicating The initial number of balls in 5 games (0<xi<1000)

Output format:
5 characters per line, separated by spaces. Respectively indicate whether the person who takes the ball first in each game can win.
If you can win, then output +.
Secondly, if there is a way to tie the opponent, output 0,
and you will lose anyway, then output-

For example, enter:
1 2 3
1 2 3 4 5

The program should output:

  • 0 + 0 -

For another example, enter:
1 4 5
10 11 12 13 15

The program should output:
0-0 + +

For another example, enter:
2 3 5
7 8 9 10 11

The program should output:

  • 0 0 0 0

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

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.
Topic analysis
topic codes



Question 9: Exchange bottles

Title description
There are N bottles, numbered 1 ~ N, placed on a shelf.

For example, there are 5 bottles:
2 1 3 5 4

It is required to pick up 2 bottles at a time and exchange their positions.
After several times, the serial number of the bottle is:
1 2 3 4 5

For such a simple situation, obviously, at least two exchanges are required to reset.

What if there are more bottles? You can solve it by programming.

The input format is two lines: the
first line: a positive integer N (N<10000), indicating the number of bottles. The
second line: N positive integers, separated by spaces, indicating the current arrangement of the bottles.

The output data is a positive integer in a row, which means how many exchanges at least to complete the sorting.

For example, enter:
5
3 1 2 5 4

The program should output:
3

For another example, enter:
5
5 4 3 2 1

The program should output:
2

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.
Topic analysis
topic codes



Question 10: Compression Transformation

Title description
Xiao Ming is currently studying compression algorithms.
He knows that if the value can be made small during compression, a higher compression ratio can be obtained through entropy coding.
However, it is a challenge to make the value small.

Recently, Xiao Ming needs to compress some sequences of positive integers. The characteristic of these sequences is that the numbers that appear later are likely to be numbers that have just appeared recently. For this special sequence, Xiao Ming is going to make a transformation on the sequence to reduce the value of the number.

The transformation process is as follows:
enumerate the sequence from left to right, and each enumerate a number. If the number has not appeared before, just convert the number to its opposite number. If the number has appeared, look at the last one in the original sequence. Several numbers appear after one occurrence (and before the current number). Replace the original number with this kind of number.

For example, the sequence (a1, a2, a3, a4, a5)=(1, 2, 2, 1, 2) in the transformation process is:
a1: 1 has never appeared, so a1 becomes -1;
a2: 2 does not appear So a2 becomes -2;
a3: 2 has appeared, and the last time is a2 of the original sequence. There are 0 numbers after a2 and before a3, so a3 becomes 0;
a4: 1 has appeared, and the last time is the original In the sequence of a1, there is 1 type of number after a1 and before a4, so a4 becomes 1;
a5: 2 has appeared, and the last time is a3 of the original sequence, and there is 1 type of number after a3 and before a5, so a5 becomes 1.
Now, given the original sequence, what is the sequence transformed according to this transformation rule.

Input format: The
first line of input contains an integer n, which represents the length of the sequence.
The second line contains n positive integers, representing the input sequence.

Output format:
output one line, containing n numbers, representing the transformed sequence.

For example, enter:
5
1 2 2 1 2

The program should output:
-1 -2 0 1 1

For another example, enter:
12
1 1 2 3 2 3 1 2 2 2 3 1

The program should output:
-1 0 -2 -3 1 1 2 2 0 0 2 2

Data scale and conventions
For 30% data, n<=1000;
for 50% data, n<=30000;
for 100% data, 1 <=n<=100000, 1<=ai<=10^9

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

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.
Topic analysis
topic codes



Guess you like

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