[Title of the 7th Blue Bridge Cup 2016] JAVA Group A

1 Number of briquettes

There is a pile of briquettes, which form a triangular pyramid. Specifically:
a first layer put 1a,
a second layer of 3a (arranged in a triangle),
a third layer 6one (arranged in a triangle),
the fourth layer 10one (arranged in a triangle),
....
if a total 100layer, total number of Briquettes?

Please fill in the number indicating the total number of briquettes.
Note: Your submission should be an integer, do not fill in any extra content or explanatory text.

2 birthday candles

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

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

Excuse me, how old has he been to the birthday party?

Please fill in the age at which he started birthday party.
Note: Your submission should be an integer, do not fill in any extra content or explanatory text.

3 Building blocks

Xiaoming likes to build digital blocks recently.
There are a total of 10blocks, and each block has a number on it 0~9.

Rule of building blocks:
Each building block is placed on top of the other two building blocks, and it must be more than the two building block numbers below .
In the end 4, the pyramids are layered, and all the building blocks must be used up.

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 the total number of such methods?

Please fill in the number indicating the total number.
Note: Your submission should be an integer, do not fill in any extra content or explanatory text.

4 subgroups

9Athletes participate in the competition, we need to divide 3the group preliminaries.
What are the grouping options?

We mark athletes A,B,C,... I
lists all of the following program grouping method.

The normal output of this program is:

ABC DEF GHI
ABC DEG FHI
ABC DEH FGI
ABC DEI FGH
ABC DFG EHI
ABC DFH EGI
ABC DFI EGH
ABC DGH EFI
ABC DGI EFH
ABC DHI EFG
ABC EFG DHI
ABC EFH DGI
ABC EFI DGH
ABC EGH DFI
ABC EGI DFH
ABC EHI DFG
ABC FGH DEI
ABC FGI DEH
ABC FHI 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, total 560lines).

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.

5 Lottery

XThe planet is going to send an 5observer group to W Star.
Among them: the
Acountry can send 4at most people.
BThe country can send 2at most people.
CThe country can send 2at most people.
....

So how many different combinations of countries will there be in the final observation mission to W Star?

The following program 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
....
(以下省略,总共101行)
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,"");
	}
}

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.

6 Winter vacation homework

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

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

(If it cannot be displayed, please refer to [Figure 1.jpg])
Insert picture description here
Each square represents a certain number from 1 to 13, but it cannot be repeated.
such as:

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

as well as:

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

Even the 两种solution. (Addition, multiplication and exchange law calculate different schemes)

How many solutions have you found?

Please fill in an integer representing the number of plans.
Note: Your submission should be an integer, do not fill in any extra content or explanatory text.

7 Cut the stamp

As shown in [Figure 1.jpg], there are stamps 12of 12zodiac signs connected together .
Now if you want to cut a 5picture from it, the requirements must be continuous.
(Only one corner is not connected) For
example, [ 图2.jpg】, 【图3.jpg】in, the part shown in pink is a qualified cut.
Insert picture description here
Insert picture description here
Insert picture description here
Please calculate how many different cutting methods there are.

Please fill in an integer representing the number of plans.
Note: Your submission should be an integer, do not fill in any extra content or explanatory text.

8 Ball-taking game

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

Assuming that both parties use the smartest way to take it, will the
first person to take the ball win?
Try programming to solve this problem.

Input format:
The first line of 3positive integers n1 n2 n3, separate spaces, each preferably represents a number of (0<n1,n2,n3<100)
the second line of 5positive integers x1 x2 ... x5, separate spaces, number 5 indicates an initial ball Board(0<xi<1000)

Output format:
one line 5of characters, separated by spaces. Respectively indicate whether the person who takes the ball first in each round will win.
+ The output can win,
followed, if any way draw with rivals, output 0,
anyway input, output -

For example, enter:

1 2 3
1 2 3 4 5

The program should output:

+ 0 + 0 -

As another example, enter:

1 4 5
10 11 12 13 15

The program should output:

0 - 0 + +

As another example, enter:

2 3 5
7 8 9 10 11

The program should output:

+ 0 0 0 0

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

9 Exchange bottles

There is Na bottle, numbered 1 ~ N, placed on the shelf.

For example, there is 5a bottle:
2 1 3 5 4

Ask to pick up 2a bottle each 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, it is clear that 2it can be reset after at least exchanges .

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: Na positive integer, separated by spaces, indicating the current arrangement of the bottles.

The output data is a line of positive integers, indicating at least how many times to exchange, to complete the sorting.

For example, enter:

5
3 1 2 5 4

The program should output:

3

As another example, enter:

5
5 4 3 2 1

The program should output:
2

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

10 Compression transformation

Xiaoming is currently working on 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, keeping the value small is a challenge.

Recently, Xiaoming 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. For this particular sequence, Xiaoming 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, each enumeration to a number, if the number has not appeared, just convert the number to its opposite number, if the number has appeared, look at the last Several numbers appear after the first occurrence (and before the current number), and 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: 1not appeared, it a1becomes -1;
a2: 2not occurred, it a2becomes -2;
a3: 2occurred, the last of the original sequence a2, in the a2rear, a3before there 0kind digital, it a3becomes 0;
a4: 1appeared, finally once the original sequence a1, in a1after, a4before there are 1kinds of numbers, it a4becomes 1;
a5: 2there have been, for the last of the original sequence a3, in a3after, a5before there are 1kinds of numbers, it a5becomes 1.
Now, given the original sequence, what is the sequence transformed according to this transformation rule?

Input format: The
first line of the input contains an integer n, indicating the length of the sequence.
The second line contains na positive integer, indicating the input sequence.

Output format:
output a line, including the nnumber, representing the transformed sequence.

For example, enter:

5
1 2 2 1 2

The program should output:

-1 -2 0 1 1

As 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 convention
For 30% of data, n <= 1000;
for 50% of data, n <= 30000;
for 100% of data, 1 <= n <= 100000, 1 <= ai <= 10 ^ 9

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

Guess you like

Origin www.cnblogs.com/HoweZhan/p/12678761.html