2016 7th Java Group B 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: 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.
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: Make up the formula

Title description

     B DEF 
A + --- + ------- = 10 
     C REC
     

(If there is a problem with the display, please refer to [Figure 1.jpg])

In this formula, A~I represent numbers from 1 to 9, and different letters represent different numbers.

For example:
6+8/3+952/714 is one solution,
5+3/1+972/486 is another solution.

How many solutions are there in this formula?

Note: Your submission should be a whole number, 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;
        }
    }
}

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



Question 6: Fill in the squares

Topic description
10 grids as follows
Insert picture description here

(If there is a problem with the display, you can also refer to [Figure 1.jpg])

Fill in the numbers from 0 to 9. Requirement: Two consecutive numbers cannot be adjacent.
(Left and right, up and down, and diagonally are all adjacent)

How many possible filling schemes are there?

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.
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.

Figure 1-3 in order
Insert picture description here
Insert picture description here
Insert picture description here

Topic analysis
topic codes



Question 8: Four square sum

Title Description The
Four Squares Theorem, also known as Lagrange's Theorem:
Every positive integer can be expressed as the sum of the squares of at most 4 positive integers.
If you include 0, it can be expressed as the sum of the squares of 4 numbers.

For example:
5 = 0^2 + 0^2 + 1^2 + 2^2
7 = 1^2 + 1^2 + 1^2 + 2^2
(^ sign means power)

For a given positive integer, there may be multiple representations of the sum of squares.
You are required to sort the 4 numbers:
0 <= a <= b <= c <= d
and arrange all possible representations in ascending order by a, b, c, d as the joint primary key, and finally output the first representation

The program input is a positive integer N (N<5000000)
. 4 non-negative integers are required to be output, sorted from small to large, separated by spaces

For example, input:
5
, the program should output:
0 0 1 2

For another example, input:
12
, the program should output:
0 2 2 2

For another example, input:
773535
, the program should output:
1 1 267 838

Resource agreement:
peak memory consumption (including virtual machine) <256M
CPU consumption <3000ms
question analysis
question code



Question 9: 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
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 machine) <256M
CPU consumption <3000ms
question analysis
question code



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 types of 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 machine) <256M
CPU consumption <3000ms
question analysis
question code



Guess you like

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