The real questions and analysis of the Blue Bridge Cup over the years .
content:
-
- The real questions and analysis of the Blue Bridge Cup over the years.
-
- A: ASC (Difficulty: ★)
- B: Space (Difficulty: ★)
- C: Card (Difficulty: ★★★)
- D: Multiply (Difficulty: ★★)
- E: Path (Difficulty: ★★★)
- F: Time display (difficulty: ★★)
- G: Minimum Weight (Difficulty: ★★★★)
- H: Yang Hui Triangle (Difficulty: ★★★★)
- I: left child right brother (difficulty: ★★★★★)
- I: Two-way sorting (difficulty: ★★★★★)
A: ASC (Difficulty: ★)
topic:
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: Space (Difficulty: ★)
topic:
analyze:
Hand calculation, one bit=1bit, 1B=8bit
64 * 1024 * 1024;
67108864
Code:
public class B空间 {
public static void main(String[] args) {
System.out.println(64 * 1024 * 1024);
}
}
C: Card (Difficulty: ★★★)
topic:
analyze:
You can enumerate from 1 onwards.
3181
Code:
public class C卡片 {
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;
}
}
}
}
D: Multiply (Difficulty: ★★)
topic:
analyze:
17812964
Code:
public class D相乘 {
public static void main(String[] args) {
for(int i=1;i<=1000000007;i++){
if(2021*(long)i%1000000007==999999999){
System.out.println(i);
}
}
}
}
E: Path (Difficulty: ★★★)
topic:
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:
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:
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:
analyze:
Violent enumeration to deceive points?
Code:
I: left child right brother (difficulty: ★★★★★)
topic:
analyze:
Load all the data into the array, and have the idea of and search.
Each time the tree is merged, the tree height is calculated, and the final height of the root node is the answer.
It can also be done without the need for a union check, multiple arrays and loop bodies can be done.
Code:
I: Two-way sorting (difficulty: ★★★★★)
topic:
analyze:
Violent CMP?