2021 12th Blue Bridge Cup first provincial competition JAVA group B Zhenti analysis (with source code and analysis)

The real questions and analysis of the Blue Bridge Cup over the years .

A: ASC (Difficulty: ★)

topic:

insert image description here

analyze:

I feel like this question is humiliating me (manual dog head
76

Code:

public class AASC {
    
    
	public static void main(String[] args) {
    
    
		System.out.println((int)'L');
	}
}

B: Card (Difficulty: ★★)

topic:

insert image description here

analyze:

You can enumerate from 1 onwards.
3181

Code:

public class B卡片 {
    
    
	public static int arr[]=new int[10];
	public static boolean del(int x){
    
    
		while(x!=0){
    
    
			arr[x%10]--;
			if(arr[x%10]<0)return false;
			x/=10;
		}
		return true;
	}
	public static void main(String[] args) {
    
    
		for(int i=0;i<10;i++)arr[i]=2021;
		for(int i=1;i<5000;i++){
    
    
			if(!del(i)){
    
    
				System.out.println(i-1);
				break;
			}
		}
	}
}

C: Straight line (Difficulty: ★★★)

topic:

insert image description here

analyze:

Use: y=kx+b, as a straight line expression.
Once k and b are determined, the straight line is determined. All statistics can be deduplicated.
40257

Code:

D: Arrangement of goods (difficulty: ★★)

topic:

insert image description here

analyze:

Enumerate the divisors of 2021041820210418, and perform multiple loop enumerations on the divisors.
Arrange all three numbers enumerated. to get the answer.
2430

Code:

E: Path (Difficulty: ★★★★)

topic:

insert image description here

analyze:

DP idea, starting from 2 to 2021, each position comes from the previous 21 positions, and
the minimum value of the 21 data can be calculated.

10266837

Code:

F: Time display (difficulty: ★)

topic:

insert image description here
insert image description here

analyze:

The simulation process can be done according to the title.

Code:

import java.util.Scanner;

public class F时间显示 {
    
    
	public static String tos(long x){
    
    
		if(x<10)return "0"+x;
		else return ""+x;
	}
	public static void main(String[] args) {
    
    
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		n%=(1000*60*60*24);
		n/=1000;
		System.out.println(tos(n/3600)+":"+tos((n/60)%60)+":"+tos(n%60));
	}
}

G: Minimum weight (difficulty: ★★★)

topic:

insert image description here
insert image description here

analyze:

Manual enumeration finds that it conforms to the ternary rule, so direct ternary calculation can be done.

Code:

import java.util.Scanner;

public class G最少砝码 {
    
    
	public static void main(String[] args) {
    
    
		Scanner sc=new Scanner(System.in);
		long x=sc.nextLong();
		long sum=1,cur=1;
		while(sum<x){
    
    
			sum+=Math.pow(3, cur);
			cur++;
		}
		System.out.println(cur);
	}
}

H: Yang Hui Triangle (Difficulty: ★★★★)

topic:

insert image description here
insert image description here

analyze:

Violent enumeration to deceive points?

Code:

I: Two-way sorting (difficulty: ★★★★★)

topic:

insert image description here
insert image description here

analyze:

Violent CMP?

Code:

J: Bracket Sequence (Difficulty: ★★★★★)

topic:

insert image description here

analyze:

Code:

insert image description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326003285&siteId=291194637