2016 Blue Bridge Cup Provincial Tournament JavaB Group

tags: java

1. Number of briquettes

There is a pile of briquettes, piled into a triangular pyramid. specific:
Put 1 on the first layer,
3 in the second layer (arranged in a triangle),
6 in the third layer (arranged in a triangle),
10 on the fourth layer (arranged in a triangle),
....
If there are 100 layers, how many briquettes are there?
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.

public class Main {
	public static void main(String[] args){
		int a=0;
		int sum=0;
		for(int i=1;i<=100;i++){
			a=a+i;
			sum=sum+a;
		}
		System.out.println(sum);
	}
	
}

The result is: 171700

2. Birthday candles
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.

public class Main {
	public static void main(String[] args){
		for(int a=1;a<=100;a++){
			int sum=0;
			for(int i=a;i<=100;i++){
				sum += i;
				if(sum==236){
					System.out.println(a);
				}	
			}
		}
	}
}
The result is: 26

3. Make up the formula
        B       DEF
A + --- + ------- = 10
        C       GHI
 
In this formula, A~I represent numbers from 1 to 9, and different letters represent different numbers.
such as:
6+8/3+952/714 is a 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.

Violent cycle (must pay attention to the problems caused by division, so change the condition to multiplication)

public class Main {
	public static void main(String[] args){
		int count = 0;
		int a,b,c,d,e,f,g,h,i;
		for(a=1;a<=9;a++){
			for(b=1;b<=9;b++){
				for(c=1;c<=9;c++){
					for(d=1;d<=9;d++){
						for(e=1;e<=9;e++){
							for(f=1;f<=9;f++){
								for(g=1;g<=9;g++){
									for(h=1;h<=9;h++){
										for(i=1;i<=9;i++){
											int GHI=g*100+h*10+i;
											int DEF=d*100+e*10+f;
											if(a!=b&&a!=c&&a!=d&&a!=e&&a!=f&&a!=g&&a!=h&&a!=i
												   &&b!=c&&b!=d&&b!=e&&b!=f&&b!=g&&b!=h&&b!=i
												         &&c!=d&&c!=e&&c!=f&&c!=g&&c!=h&&c!=i
												               &&d!=e&&d!=f&&d!=g&&d!=h&&d!=i
												                     &&e!=f&&e!=g&&e!=h&&e!=i
												                           &&f!=g&&f!=h&&f!=i
												                                 &&g!=h&&g!=i
												                                       &&h!=i
												                                       &&((a-10)*c*GHI+b*GHI+c*DEF==0))
											{
												count+=1;
											}
													
										}
									}
								}
							}
						}
					}
				}
			}
		}
		System.out.println(count);
	}


}

The result is: 29

4. Sub-group
Nine athletes participate in the competition and 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.
The normal output of the 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, 560 lines in total).

First select A and sort the combination of 3 numbers

public class Main {
	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(s+" "+(char)('A'+i)+(char)('A'+j)+(char)('A'+k)+" "+remain(a) ); //Fill in the blank position
					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. Draw lots
What about different combinations of fewer countries?
The following procedure solves this problem.
The array a[] is the largest number of places that each country can send.
The results of the program execution are:
DEFFF
CEFFF
CDFFF
CDEFF
CCFFF
CCEFF
CCDFF
CCDEF
BEFFF
BDFFF
BDEFF
BCFFF
BCEFF
BCDFF
BCDEF
....
(Omitted below, a total of 101 lines)

Nested loop

public class Main {
	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++){
			 f(a,k+1,5-s2.length(),s2); //fill in the blank position
			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.

Intelligent Recommendation

Blue Bridge Cup 2020, 11th Javab Group Provincial Tournament

Blue Bridge Cup 2020, 11th Javab Group Provincial Tournament A: House making Idea: How many 2 can be judged 1-2020, and the code is easy to implement Answer: 624 B: Looking for 2020 Idea: Traverse eve...

The 4th Blue Bridge Cup Javab Group Provincial Tournament - Revitalizing China

The 4th Blue Bridge Cup Javab Group Provincial Tournament - Revitalizing China Topic description Xiaoming participated in the fun gain of the school, one of which is: jumping. Painted some plaids on t...

2020 Eleventh Blue Bridge Cup Javab Group Provincial Tournament

The first question is 1 to 2020 has a few '2' Direct traversal answer: 624 Question 2 find 2020 Direct traversal I am manual copying of the array to measure the array is 300 * 300, and then programmat...

2020, Blue Bridge Cup Provincial Tournament Javab Group Looking for 2020

Simple simulation To the right, down, to the right...

The 11th Blue Bridge Cup Provincial Tournament Javab Group - Looking for 2020

【Problem Description】 Small blue has a digital matrix, which contains only numbers 0 and 2. Xiao Lan likes 2020, he wants to find How many 2020 is present in this digital matrix. Small blue only follo...

More Recommendation

Blue Bridge Cup 2013 Provincial Tournament [Fourth] -JAVAB Group Analysis

Refer to the snippet and official code given by the official website of the Blue Bridge. Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Time: 4 hours A. Week at the end ...

[Blue Bridge Cup Provincial Javab Group True Detail] Lottery (2016)

Topic description Draw X planets must send a 5-person observation group to Wars. in: A country can send up to 4 people. You can send up to 2 people in B country. Channel can send up to 2 people. &hell...

2018 Provincial Blue Bridge Cup JavaB Group

First question: the first few days solution: Second question: check the grid As shown in Figure p1.png, there are countless small 1x1 squares on the 2D plane. We draw a circle with a radius of 1000 ce...

Blue Bridge Cup Javab Group 2016

topic Birthday candle Some Jun started a birthday party from a year, and every time you have a candle with the same roots. Now, he has a total of 236 candles. Excuse me, how many years old began birth...

The 9th Blue Bridge Cup Provincial Tournament javaB group answers April 1, 2018

The provincial test was a mess. I didn’t know how to do many questions. I blamed myself for being too awkward. The following are some answers to questions 1-6 of the provincial contest. Later 1....

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top