- 2021-04-18 19:33
*views 3*- algorithm
- javaB
- Java
- Blue Bridge Cup

<>2021 Blue Bridge Cup university Java B Group real questions and personal code

Ben Xiaocai chicken participated in the first Blue Bridge Cup competition , Before, I always saw the boss evaluate the Blue Bridge Cup as “ Water cup ”, assume ： Yo , It's not easy （ Crazy face beating after the game ）

It is said that the difficulty of the Blue Bridge Cup is higher than that of the previous year , harm It's understandable that you can't write it .

<>2021 University Java B Group true questions

The 12th Blue Bridge Cup software competition provincial competition

Java university B group

1. Notes to candidates

2. Completion

2.1

test questions A: ASC

Total score of this question ：5 branch

【 Problem description 】

Known capital letters A of ASCII Code is 65, Capital letters, please L of ASCII What's the code ?

【 Answer submission 】

This is a question to fill in the blanks , You just need to calculate the results and submit them . The result of this question is one

Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

2.2

test questions B: card

Total score of this question ：5 branch

【 Problem description 】

Xiaolan has many digital cards , There are numbers on each card 0 reach 9.

Xiao Lan is going to spell some numbers with these cards , He wants to start from 1 Start spelling positive integers , Each spell one ,

Just keep it , Cards can't be used to spell other numbers .

Xiaolan wants to know what she can do from 1 How much do you spell .

for example , When Xiaolan has 30 Card , among 0 reach 9 various 3 Zhang , Then little blue can spell 1 reach 10,

But spell 11 Time card 1 There's only one , Not enough to spell 11.

Now Xiaolan has it in her hand 0 reach 9 Each card 2021 Zhang , common 20210 Zhang , Can Xiaolan go from 1

How much do you spell ?

Tips ： It is recommended to use computer programming to solve the problem .

2.3

test questions C: straight line

Total score of this question ：10 branch

【 Problem description 】

In plane rectangular coordinate system , Two points can determine a straight line . If there are multiple points on a straight line ,

Then the straight line determined by any two of these points is the same .

On a given plane 2 × 3 A whole point {(x,y)|0 ≤ x < 2,0 ≤ y < 3, x ∈ Z,y ∈ Z}, Abscissa

yes 0 reach 1 ( contain 0 and 1) Integer between , The ordinate is 0 reach 2 ( contain 0 and 2) Integer between

Point of . These points have been determined 11 Different lines .

On a given plane 20 × 21 A whole point {(x,y)|0 ≤ x < 20,0 ≤ y < 21, x ∈ Z,y ∈ Z}, Namely horizontal

The coordinates are 0 reach 19 ( contain 0 and 19) Integer between , The ordinate is 0 reach 20 ( contain 0 and 20) of

Points of integers between . How many different straight lines are determined by these points .

2.4

test questions D: Cargo placement

Total score of this question ：10 branch

【 Problem description 】

Xiaolan has a huge warehouse , Can put a lot of goods .

Now? , Xiao Lanyou n Boxes of goods shall be placed in the warehouse , Each box of goods is a regular cube . Blue

The length is specified , wide , Three directions perpendicular to each other , The sides of each case must be strictly parallel to the length ,

wide , high .

Xiaolan hopes that all the goods will eventually be placed into a big cube . That is, in the long , wide , High direction

Separate heap L,W,H Goods , satisfy n = L × W × H.

given n, How many schemes for stacking goods meet the requirements .

for example , When n = 4 Time , Have the following 6 Kinds of schemes ：1×1×4,1×2×2,1×4×1,2×1×2,

2 × 2 × 1,4 × 1 × 1.

Excuse me? , When n = 2021041820210418 （ Attention there 16 Digit number ） Time , How many are there altogether

programme ?

Tips ： It is recommended to use computer programming to solve the problem .

2.5

test questions E: route

Total score of this question ：15 branch

【 Problem description 】

Xiaolan is very happy after learning the shortest path , He defined a special graph , Hope to find the map

Shortest path in .

Little blue's picture is by 2021 Composed of nodes , Serial number 1 to 2021.

For two different nodes a, b, If a and b The absolute value of the difference is greater than 21, Then there are two nodes

There are no edges connected ; If a and b The absolute value of the difference is less than or equal to 21, Then there is a line between the two points

Count Reg a and b The undirected edge of the least common multiple of .

for example ： node 1 And node 23 There are no edges connected ; node 3 And node 24 There is a none between

To the side , Count Reg 24; node 15 And node 25 There is an undirected edge between , Count Reg 75.

Please calculate , node 1 And node 2021 What is the shortest path length between .

Tips ： It is recommended to use computer programming to solve the problem .

3. Programming problem

3.1

test questions F: Time display

time limit : 1.0s Memory limit : 512.0MB Total score of this question ：15 branch

【 Problem description 】

Xiaolan wants to cooperate with her friends to develop a time display website . On the server , Friends have obtained

The current time has been , Expressed as an integer , The value is from 1970 year 1 month 1 day 00:00:00 To current time

Milliseconds elapsed .

Now? , Xiaolan wants to display this time on the client . Little blue doesn't need to show the date , It only needs

Display the hours, minutes and seconds , Milliseconds are not displayed , Just throw it away .

Give a time expressed as an integer , Please output the hour, minute and second corresponding to this time .

【 Input format 】

The input line contains an integer , Represents time .

【 Output format 】

Output the current time in minutes and seconds , Format as HH:MM:SS, among HH Representation time , value

by 0 reach 23,MM Expressed score , Value is 0 reach 59,SS Indicates seconds , Value is 0 reach 59. Time , branch , second

Fill in the leading when it is less than two digits 0.

【 sample input 1】

46800999

【 sample output 1】

13:00:00

【 sample input 2】

1618708103123

【 sample output 2】

01:08:23

【 Scale and agreement of evaluation cases 】

For all profiling cases , The given time is no more than 10 18 Positive integer of .

3.2

test questions G: Minimum weight

time limit : 1.0s Memory limit : 512.0MB Total score of this question ：20 branch

【 Problem description 】

You have a balance . Now you have to design a set of weights , So that any weight can be weighed with these weights

Less than or equal to N Positive integer weight of .

How many weights should this set of weights contain at least ?

Note that the weight can be placed on both sides of the balance .

【 Input format 】

The input contains a positive integer N.

【 Output format 】

Output an integer representing the answer .

【 sample input 】

7

【 sample output 】

3

【 Example description 】

3 The weight of each weight is 1,4,6, Can weigh 1 to 7 All weights of .

1 = 1;

2 = 6 − 4 ( Put the balance aside 6, On the other side 4);

3 = 4 − 1;

4 = 4;

5 = 6 − 1;

6 = 6;

7 = 1 + 6;

Less than 3 A weight cannot be weighed 1 to 7 All weights of .

【 Scale and agreement of evaluation cases 】

For all profiling cases ,1 ≤ N ≤ 1000000000.

3.3

test questions H: Yang Hui triangle

time limit : 5.0s Memory limit : 512.0MB Total score of this question ：20 branch

【 Problem description 】

The following figure is the famous Yang Hui triangle ：

If we press from top to bottom , Arrange all the numbers in a row from left to right , You can get the following

series ：

1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1, …

Given a positive integer N, Please output the first time in the sequence N What number is it ?

【 Input format 】

Enter an integer N.

【 Output format 】

Output an integer representing the answer .

【 sample input 】

6

【 sample output 】

13

【 Scale and agreement of evaluation cases 】

about 20% Evaluation use cases for ,1 ≤ N ≤ 10;

For all profiling cases ,1 ≤ N ≤ 1000000000.

3.4

test questions I: Bidirectional sorting

time limit : 5.0s Memory limit : 512.0MB Total score of this question ：25 branch

【 Problem description 】

Given sequence (a 1 ,a 2 ,··· ,a n ) = (1,2,··· ,n), Namely a i = i.

Xiaolan will test this sequence m Secondary operation , Every time it may be a 1 ,a 2 ,··· ,a q i Descending order ,

Or will a q i ,a q i +1 ,··· ,a n Ascending arrangement .

Request the sequence after the operation is completed .

【 Input format 】

The first line of input contains two integers n, m, Represents the length of the sequence and the number of operations, respectively .

next m Line describes the operation on the sequence , Among them i The row contains two integers p i , q i Represents the operation

Types and parameters . When p i = 0 Time , Indicates that it will a 1 ,a 2 ,··· ,a q i Descending order ; When p i = 1 Time , express

take a q i ,a q i +1 ,··· ,a n Ascending arrangement .

【 Output format 】

Output one line , contain n Integer , Adjacent integers are separated by a space , Represents the operation

Sequence after completion .

【 sample input 】

3 3

0 3

1 2

0 2

【 sample output 】

3 1 2

【 Example description 】

The original sequence is (1,2,3).

The first 1 After step (3,2,1).

The first 2 After step (3,1,2).

The first 3 After step (3,1,2). And section 2 Same after step operation , Because the first two numbers are in descending order .

【 Scale and agreement of evaluation cases 】

about 30% Evaluation use cases for ,n,m ≤ 1000;

about 60% Evaluation use cases for ,n,m ≤ 5000;

For all profiling cases ,1 ≤ n,m ≤ 100000,0 ≤ a i ≤ 1,1 ≤ b i ≤ n.

3.5

test questions J: Bracket sequence

time limit : 5.0s Memory limit : 512.0MB Total score of this question ：25 branch

【 Problem description 】

Given a sequence of parentheses , It is required to add as few parentheses as possible to make the sequence of parentheses legal ,

When the addition is complete , Different addition results will be produced , How many essentially different addition results are there .

The two results are essentially different, which means that there is a certain position, and one result is the left parenthesis , And the other is right

number .

for example , For parenthesis sequences (((), Just add two parentheses to make it legal , There are the following

Different addition results ：()()(),()(()),(())(),(()()) and ((())).

【 Input format 】

The input line contains a string s, Represents the given sequence of parentheses , There are only left parentheses and in the sequence

Right parenthesis .

【 Output format 】

Output an integer to represent the answer , The answer may be big , Please output the answer divided by 1000000007 ( Namely

10 9 + 7) Remainder of .

【 sample input 】

((()

【 sample output 】

5

【 Scale and agreement of evaluation cases 】

about 40% Evaluation use cases for ,|s| ≤ 200.

For all profiling cases ,1 ≤ |s| ≤ 5000.

Personal answer sharing

（ Only two blanks and two programs are written , It's really delicious , I don't know if it's right ）

The first multiple-choice question is omitted

Second multiple choice question

public class lanqiao_1 { public static void main(String[] args) { int ling=2021

; int yi=2021; int er=2021; int san=2021; int si=2021; int wu=2021; int liu=2021

; int qi=2021; int ba=2021; int jiu=2021; int shi=2021; int count=0; for(int i=1

;i<202100;i++) { if((ling+1)>0) if((yi+1)>0) if((er+1)>0) if((san+1)>0) if((si+1

)>0) if((wu+1)>0) if((liu+1)>0) if((qi+1)>0) if((ba+1)>0) if((jiu+1)>0) {

String num=i+"A"; if(num.contains("0")) ling--; if(num.contains("1")) yi--; if(

num.contains("2")) er--; if(num.contains("3")) san--; if(num.contains("4")) si--

; if(num.contains("5")) wu--; if(num.contains("6")) liu--; if(num.contains("7"))

qi--; if(num.contains("8")) ba--; if(num.contains("9")) jiu--; count++;

//System.out.println(count); } } System.out.println(count); } }

This code is very funny, ha ha ha

Yang Hui triangle

public class lanqiao_H { public static void main(String[] args) { int [][]a=new

int[100][100]; int []b=new int[10000]; Scanner sc =new Scanner(System.in); int n

=sc.nextInt(); int count=0; for(int i=0;i<100;i++) { for(int j=0;j<=i;j++) { if(

j==0) a[i][0]=1; if(i==j) a[i][j]=1; } } for(int i=2;i<100;i++) { for(int j=1;j<

i;j++) { a[i][j]=a[i-1][j-1]+a[i-1][j]; } } int k=0; for(int i=0;i<100;i++) for(

int j=0;j<=i;j++) { b[k]=a[i][j]; k++; } for(int i=0;i<10000;i++) { if(n==1) {

count=1; break; } if(b[i]==n) { count=i+1; break; } } System.out.print(count); }

}

Bidirectional sorting

public class lanqiao_H { public static void main(String[] args) { int [][]a=new

int[100][100]; int []b=new int[10000]; Scanner sc =new Scanner(System.in); int n

=sc.nextInt(); int count=0; for(int i=0;i<100;i++) { for(int j=0;j<=i;j++) { if(

j==0) a[i][0]=1; if(i==j) a[i][j]=1; } } for(int i=2;i<100;i++) { for(int j=1;j<

i;j++) { a[i][j]=a[i-1][j-1]+a[i-1][j]; } } int k=0; for(int i=0;i<100;i++) for(

int j=0;j<=i;j++) { b[k]=a[i][j]; k++; } for(int i=0;i<10000;i++) { if(n==1) {

count=1; break; } if(b[i]==n) { count=i+1; break; } } System.out.print(count); }

}

Technology

- Python172 blogs
- Java151 blogs
- Vue91 blogs
- Flow Chart80 blogs
- C++50 blogs
- algorithm47 blogs
- javascript46 blogs
- programing language43 blogs
- more...

Daily Recommendation

views 11

views 9

views 8

©2020-2021 ioDraw All rights reserved

use Android Studio Designed a simple alarm clock APP use C Language writing bank ATM Code of ATM deposit and withdrawal 2021-11-13JavaScript Hundred refining into Immortals 1.14 Show java_ Guessing games —— The mystery of flow In order to improve work efficiency ： adopt pycharm Template code to reduce duplication of effort The beauty of data visualization -- with Matlab,Python As a tool centos Accidental deletion recovery Binary tree , Full binary tree and complete binary tree --Java Data structures and algorithms 【 Take you to brush with your hands LeetCode】——19. Narcissistic number （ task ）