The third simulation match of the 12th Blue Bridge Cup

Posted by MobiTec on Tue, 08 Mar 2022 15:17:00 +0100

The third simulation match of the 12th Blue Bridge Cup

Question A
Total score of this question: 5 points

[problem description]
From 1 to 2020, how many numbers are coprime with 2020, that is, how many numbers are the maximum common divisor of 2020 is 1.

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

```package _12 12th simulation match 03;
/*
* Question A
Total score of this question: 5 points

[Problem description]
From 1 to 2020, how many numbers are coprime with 2020, that is, how many numbers are the maximum common divisor of 2020 is 1.

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.
*/
public class A Coprime number {
public static void main(String[] args) {
int ans=0;
for(int i=1;i<=2020;i++) {
if(gcd(i,2020)==1) {
ans++;
}
}

//System.out.println(3%2020);
System.out.println(ans);
}
private static int gcd(int a, int b) {
return a%b ==0?b :gcd(b,a%b);
}
}

```

Question B
Total score of this question: 5 points

[problem description]
ASCII code corresponds each character to a numerical value (code) for information representation and transmission. In ASCII code, English letters are coded from small to large. For example, the code of letter A is 65, the code of letter B is 66, and the code of letter C is 67. What is the code of letter Q?

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

```package _12 12th simulation match 03;
/*
* Question B
Total score of this question: 5 points

[Problem description]
ASCII The code corresponds each character to a numerical value (code) for the representation and transmission of information. In ASCII code, English letters are coded from small to large. For example, the code of letter A is 65, the code of letter B is 66, and the code of letter C is 67. What is the code of letter Q?

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

*/
public class B code {
public static void main(String[] args) {
System.out.println('Q'+0);
}
}

```

Test question C
Total score of this question: 10 points

[problem description]
There is a binary tree with 2021 nodes, including 1000 nodes and two child nodes,
Other nodes have one or 0 child nodes.
How many leaf nodes does this binary tree have?

```package _12 12th simulation match 03;
/*
* Test question C
Total score of this question: 10 points

[Problem description]
There is a binary tree with 2021 nodes, including 1000 nodes and two child nodes,
Other nodes have one or 0 child nodes.
How many leaf nodes does this binary tree have?

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

*/
public class C {
public static void main(String[] args) {
System.out.println((int)(Math.pow(2, 10-1)-23)*2+23); //In fact, I didn't understand it. There are leaders who understand it,
}
}

```

4,
[problem description]
For integers v and p, the Pierce sequence is defined as:
a[1] = v
a[i] = p % a[i-1]
For example, when v = 8 and P = 21, the corresponding Pierce sequence is
a[1] = 8
a[2] = 5
a[3] = 1
Later, the value becomes 0, which is not within our consideration. Therefore, when v = 8 and P = 21, the length of Pierce sequence is 3.
When p is constant, the length of Pierce sequence may be different for different V values. When p = 8, if 1 < = V < p, the longest pierce sequence appears when v=13, which is (13, 8, 5, 1) and the length is 4.
When p=2021, the longest Pierce sequence appears when v=1160. How long is this sequence?

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

```package _12 12th simulation match 03;
/*
* Total score of this question: 10 points

[Problem description]
For integers v and p, the Pierce sequence is defined as:
a[1] = v
a[i] = p % a[i-1]
For example, when v = 8 and P = 21, the corresponding Pierce sequence is
a[1] = 8
a[2] = 5
a[3] = 1
Later, the value becomes 0, which is not within our consideration. Therefore, when v = 8 and P = 21, the length of Pierce sequence is 3.
When p is constant, the length of Pierce sequence may be different for different V values. When p = 8, if 1 < = V < p, the longest pierce sequence appears when v=13, which is (13, 8, 5, 1) and the length is 4.
When p=2021, the longest Pierce sequence appears when v=1160. How long is this sequence?

This is a question filled in with results. You just need to calculate the results and submit them. The result of this question is an integer. When submitting the answer, only fill in this integer. If you fill in the redundant content, you will not be able to score.

*/
public class D {
public static void main(String[] args) {
int ant=1;
int p=2021;
int v=1160;
while(p%v!=0) {
int newv =p%v;
v=newv;
ant++;
}
System.out.println(ant);
}

}

```