Detailed explanation and summary of the real questions for the 1st simulation contest of the 12th Blue Bridge Cup in 2021 [Java Edition]


  1. 2013 04th Blue Bridge Cup Java Group B provincial competition detailed explanation and summary
  2. Detailed explanation and summary of the real questions in the 05th Blue Bridge Cup Java Group B Provincial Competition in 2014
  3. Detailed explanation and summary of the real questions in the 2015 Blue Bridge Cup Java Group B Provincial Competition
  4. 2016 07th Blue Bridge Cup Java Group B provincial competition detailed explanation and summary
  5. 2017 08th Blue Bridge Cup Java Group B provincial competition detailed explanation and summary
  6. Detailed explanation and summary of the real questions of the 09th Blue Bridge Cup Java Group B Provincial Competition in 2018
  7. 2019 10th Blue Bridge Cup Java Group B provincial competition detailed explanation and summary
  8. 2020 The detailed explanation and summary of the real questions of the 1st simulation contest of the 11th Blue Bridge Cup [Java Edition] (in-school simulation) //  Official explanation video
  9. In 2020, the detailed explanation and summary of the real questions of the 2nd simulation contest of the 11th Blue Bridge Cup [Java Edition] //  Official explanation video
  10. 2020 The 11th Blue Bridge Cup C/C++ Group B provincial competition detailed explanation and summary [The 1st provincial competition 2020.07.05] [Java Edition]
  11. 2020 The 11th Blue Bridge Cup Java Group B provincial competition detailed explanation and summary [The 1st provincial competition 2020.07.05]
  12. Detailed explanation and summary of the real questions of the 11th Blue Bridge Cup Java Group B Provincial Tournament in 2020 [The 2nd Provincial Tournament 2020.10.17]
  13. 2020 The 11th Blue Bridge Cup Java Group C provincial competition detailed explanation and summary [The first provincial competition 2020.07.05]
  14. Detailed explanation and summary of the real questions for the 1st simulation contest of the 12th Blue Bridge Cup in 2021 [Java Edition]
  15. Detailed explanation and summary of the real questions of the second simulation contest of the 12th Blue Bridge Cup in 2021 [Java Edition]
  16. Detailed explanation and summary of the real questions in the 12th Blue Bridge Cup Java Group B Provincial Competition in 2021

  1. Detailed explanation and summary of the real questions in the 2015 Blue Bridge Cup Java Group B finals
  2. 2016 07th Blue Bridge Cup Java Group B finals detailed explanation and summary
  3. 2017 08th Blue Bridge Cup Java Group B finals detailed explanation and summary
  4. Detailed explanation and summary of the real questions in the 2018 9th Blue Bridge Cup Java Group B Finals
  5. Detailed explanation and summary of the real questions in the 10th Blue Bridge Cup Java Group B finals in 2019
  6. Detailed explanation and summary of the real questions in the 11th Blue Bridge Cup Java Group B finals in 2020

table of Contents

Screenshot of the mock contest webpage

1. Test Question A-Answer: 25600

Solution 1: Calculator solution

Solution 2: Programming solution

2. Question B-Answer: 12

Solution 1: for loop + check

3. Test Question C-Answer: 6973

Solution 1: String splicing

4. Question D-Answer: 2039190

Solution one: cumulative sum

5. Question E-Answer: 217

Solution 1: Double for loop to traverse all combinations

Six, test question F

Solution 1: Check the month first -> check the number of days

Seven, test question G

Solution 1: String.format();

8. Question H

Solution 1: [Cannot write! Begging giants to help!

Nine, test questions I

Solution 1: Single-layer for loop

10. Test Question J

Solution 1: [Cannot write! Begging giants to help!

summary


Written by myself, for reference only, welcome to communicate! ! !

Screenshot of the mock contest webpage

   

   

   

   

1. Test Question A-Answer: 25600

Problem Description

  If an mp3 file occupies a disk size of 4MB, and Xiaolan’s hard drive has 100GB of space left, how many more such mp3 files can he put?

Answer submission

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

Solution 1: Calculator solution

[Answer]: 25600

[Analysis]: 1GB = 1024MB.

Solution 2: Programming solution

2. Question B-Answer: 12

Problem Description

  If the integer a is an integer multiple of the integer b, then b is a divisor of a.
  Excuse me, how many positive integers are the divisors of 2020.

Answer submission

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

Solution 1: for loop + check

[Answer]: 12

package simulationMatch_12_2021_1;

public class _02B {

	public static void main(String[] args) {
		int answer = 0;
		for (int i = 1; i <= 2020; i++) {
			if (2020 % i == 0) {
				System.out.print(i + "、");
				answer++;
			}
		}
		System.out.println();
		System.out.println(answer);
	}

}

3. Test Question C-Answer: 6973

Problem Description

  The integers 1 to 6 are concatenated together to become 123456 and the length is 6.
  The integers 1 to 12 are concatenated to become 123456789101112, and the length is 15.
  What is the length of the integers 1 to 2020 connected together?

Answer submission

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

Solution 1: String splicing

[Answer]: 6973

package simulationMatch_12_2021_1;

public class _03C {

	public static void main(String[] args) {
		String str = "";
		for (int i = 1; i <= 2020; i++) {
			str += i;
		}
		System.out.println(str);
		System.out.println(str.length());
	}

}

4. Question D-Answer: 2039190

Problem Description

  An undirected graph containing 2020 nodes, if there are no self-loops and double edges in the graph, how many edges can it contain at most?

Answer submission

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

Solution one: cumulative sum

[Answer]: 2039190

[Analysis]: Find a pattern!

package simulationMatch_12_2021_1;

public class _04D {

	public static void main(String[] args) {
		int answer = 0;
		for (int i = 1; i <= 2019; i++) {
			answer += i;
		}
		System.out.println(answer);
		System.out.println(2019 * (1 + 2019) / 2); // 等差数列求和公式
	}

}

5. Question E-Answer: 217

Problem Description

  In a sequence a = (a[1], a[2], ..., a[n]), if (i, j) satisfies i <j and a[i]> a[j], then It is a reverse pair.
  For example: (3, 2, 2, 1) contains 6 reverse pairs.
  Excuse me, (87, 39, 35, 1, 99, 10, 54, 1, 46, 24, 74, 62, 49, 13, 2, 80, 24, 58, 8, 14, 83, 23, 97, 85 , 3, 2, 86, 10, 71, 15) How many reverse pairs are included?

Answer submission

  This is a fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

Solution 1: Double for loop to traverse all combinations

(3, 2, 2, 1) How to include 6 pairs in reverse order? ? ? It shouldn't be 5! ! !

Reverse sequence pairs: Line 1, Line 2, Line 3, Line 5, Line 6.

So, I feel that the question is wrong! ! !

package simulationMatch_12_2021_1;

public class _05E {

	public static void main(String[] args) {
		int arr1[] = { 3, 2, 2, 1 };
		int arr2[] = { 87, 39, 35, 1, 99, 10, 54, 1, 46, 24, 74, 62, 49, 13, 
				2, 80, 24, 58, 8, 14, 83, 23, 97, 85, 3, 2, 86, 10, 71, 15 };
		solve(arr1);
		solve(arr2);
	}

	public static void solve(int arr[]) {
		int answer = 0;
		for (int i = 0; i < arr.length; i++) {
			for (int j = 0; j < arr.length; j++) {
				if (i < j && arr[i] > arr[j]) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}

}

Six, test question F

Problem Description

  Xiaolan is in elementary school, and the teacher asks the students to keep a diary every summer during the summer vacation. But Xiaolan spent the entire summer vacation, and didn't remember to keep a diary until the last day. So Xiaolan quickly compiled some diaries and gave them to the teacher.
  Unexpectedly, the teacher found the problem in the diary soon. It turned out that Xiaolan finished the diary on August 31st, but he recorded the diary on August 32 and August 33. This is obviously problematic, because there are no August 32 and August 33.
  Given a month and a date, is there such a day in 2021?

Input format

  The first line of input contains an integer m, which represents the month.
  The second line contains an integer d, which represents the date.

Output format

  If there is m month d in 2021, enter yes, otherwise output no.

Sample input

8
32

Sample output

no

Sample input

2
28

Sample output

yes

Data size and convention

  For all evaluation cases, 1 <= m <= 20 and 1 <= d <= 40.

Solution 1: Check the month first -> check the number of days

[Analysis]: 2021 is a normal year and there are only 28 days in February ! (Just look at the calendar on the computer!)

1 <= m <= 20,1 <= d <= 40。

package simulationMatch_12_2021_1;

import java.util.Scanner;

public class _06F {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		if (m == 2) {
			if (1 <= d && d <= 28) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		} else if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
			if (1 <= d && d <= 31) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		} else if (m == 4 || m == 6 || m == 9 || m == 11) {
			if (1 <= d && d <= 30) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		} else if (m >= 13) {
			System.out.println("no");
		}
	}
}

Seven, test question G

Problem Description

  Given the length l and height h of the base of a triangle, find the area of ​​the triangle.

Input format

  The first line of input contains an integer l, which represents the length of the base of the triangle.
  The second line contains an integer h, which represents the height of the triangle.

Output format

  Output a number that represents the area of ​​the triangle. If the area is an integer, please output this integer directly without a decimal point. If the area is not a whole number, please round up to exactly one decimal place.

Sample input

5
6

Sample output

15

Sample input

5
3

Sample output

7.5

Data size and convention

  For all evaluation cases, 1 <= l, h <= 100.

Solution 1: String.format();

package simulationMatch_12_2021_1;

import java.util.Scanner;

public class _07G {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int h = sc.nextInt();
		int s = l * h / 2;
		if (l * h == s * 2) { // 面积是整数
			System.out.println(l * h / 2);
		} else { // 面积非整数
			double ll = l;
			double hh = h;
			System.out.println(String.format("%.1f", (ll * hh / 2)));
		}
	}

}

8. Question H

Problem Description

  Given a word, after deleting t letters in the word, what is the smallest word in the dictionary?

Input format

  The first line of input contains a word consisting of uppercase English letters.
  The second line contains a positive integer t.

Output format

  Output a word to indicate the answer

Sample input

LANQIAO
3

Sample output

AIAO

Data size and convention

  For all evaluation cases, the word length does not exceed 100, and t is less than the word length.

Solution 1: [Cannot write! Begging giants to help!

[Analysis]: First add the letters with the highest ASCII value in the string to the set big,

Traverse the string from front to back, and remove the characters contained in the big set (characters with large ASCII values ​​are preferred).

Can't write! ! ! Begging giants to help! ! !

package simulationMatch_12_2021_1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class _08H {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		int t = sc.nextInt();

		char ch[] = str.toCharArray();
		Arrays.sort(ch); // 对字符数组进行排序,筛选出ASCII值的字符
		System.out.println(Arrays.toString(ch));
		char charMax[] = new char[t]; // 将ASCII最大的t个字符存到chMax数组中
		for (int i = 0; i < t; i++) {
			charMax[i] = ch[str.length() - 1 - i];
		}
		System.out.println(Arrays.toString(charMax));

		char strChar[] = str.toCharArray();
		ArrayList<Character> list = new ArrayList<Character>();
		for (int i = 0; i < strChar.length; i++) {
			list.add(strChar[i]);
		}
		boolean flag;
		for (int i = 0; i < str.length(); i++) {
			flag = true;
			for (int j = 0; j < t; j++) {
				if (list.get(i).equals(charMax[j])) {
					flag = false;
				}
			}
			if (flag) {
				System.out.print(list.get(i) + "");
			}
		}
	}

}

Nine, test questions I

Problem Description

  Given a sequence a_1, a_2, ..., a_n. Where a_1 <a_2 <... <a_n.
  The difference between two adjacent numbers (the next number minus the previous number) is called their gap.
  What is the maximum gap value in the sequence?

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, which is a given sequence.

Output format

  Output an integer that represents the largest gap value in the sequence.

Sample input

5
1 3 8 9 12

Sample output

5

Sample description

  a_3 - a_2 = 5。

Data size and convention

  For all test cases, 1 <= n <= 1000, 1 <= a_i <= 100000.

Solution 1: Single-layer for loop

[Analysis]: A single-layer for loop traverses the array once!

package simulationMatch_12_2021_1;

import java.util.Scanner;

public class _09I {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n + 5];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		if (n == 1) {
			System.out.println(arr[0]);
		} else {
			int max = arr[1] - arr[0];
			for (int i = 0; i < n - 1; i++) {
				// System.out.println(arr[i + 1] + "-" + arr[i]);
				if (max < arr[i + 1] - arr[i]) {
					max = arr[i + 1] - arr[i];
				}
			}
			System.out.println(max);
		}
	}

}

10. Test Question J

Problem Description

  Little Blue has three colored balls of yellow, green and blue, namely R, G, and B. There is no difference between balls of the same color.
  Xiao Lan arranges these balls in a row from left to right. After the row is finished, the number of consecutive balls of the same color on the far left is recorded as t_1, and the next number of consecutive balls is recorded as t_2, and so on until The ball on the far right.
  Excuse me, how many total placement schemes are there to make t_1, t_2, ... a strictly monotonically increasing sequence, that is, t_1 <t_2 <t_3 <...

Input format

  Enter a line containing three integers R, G, B.

Output format

  Output an integer to indicate the answer.

Sample input

3 6 0

Sample output

3

Sample description

  Use r to denote the red ball and g to denote the green ball. Possible solutions include:
  rrrgggggg
  grrrggggg
  ggrrrgggg

Sample input

2 4 6

Sample output

3

Sample description

  Use r to represent the red ball, g to represent the green ball, and b to represent the blue ball. Possible solutions include:
  rrggggbbbbbb
  grrgggbbbbbb
  brrggggbbbbb

Data size and convention

  For 30% of the evaluation cases, 1 <= R, G, B <= 10;
  for 60% of the evaluation cases, 1 <= R, G, B <= 30;
  for all evaluation cases, 1 <= R, G, B <= 50.

Solution 1: [Cannot write! Begging giants to help!

Difficult, can't write... Please help me...

summary

Carefully, seriously, come on! ! ! Pay attention to the upper and lower bounds of variables ! ! !

Guess you like

Origin blog.csdn.net/weixin_44949135/article/details/111873706