2020 10th C/C++ Group B First Blue Bridge Cup Provincial Match

Here is the topic column of the Blue Bridge Cup over the years. It will be updated successively and the real questions and answers of previous years will be released. I welcome you to follow me. Your likes and attention are the best motivation for me! ! !
The real questions are updated every day, so stay tuned

Blue Bridge Cup real questions and detailed answers over the years


Question 1: Running training (5 points)

Topic description
Xiao Ming is going to do a running training.
Initially, Xiao Ming is full of stamina, and the stamina value is calculated as 10000. If Xiao Ming runs, he loses 600 stamina per minute. If Xiao Ming rests, increase his stamina by 300 per minute. Both the loss and gain of stamina vary evenly.
Xiao Ming plans to run for one minute, rest for one minute, run for another minute, rest for another minute... and so on. If Xiao Ming's stamina reaches 0 at some point, he stops exercising.
May I ask how soon after Xiaoming stops exercising? To make the answer an integer, output the answer in seconds. Only fill in the number in the answer, not the unit.
Topic analysis
First find the loss per second, then simulate the exercise process of running and rest, you can
code the topic

#include<iostream>

using namespace std;

int main()
{
    
    
	int n = 10000;
	int run = 600/60;//每秒的消耗 
	int time = 0;
	while(n)
	{
    
    
		
		if(n-600 <0)
		{
    
    
			time  = time*60+n/run;
			break;
		}
		n-=600;
		n+=300;
		time+=2;
	}
	cout << time;
	return 0;
} 

question answer

3880

Question 2: Remembrance Day (5 points)

Title Description
July 1, 2020 is the 99th anniversary of the founding of the Communist Party of China.
The Communist Party of China was founded on July 23, 1921.
How many minutes are there from 12:00 noon on July 23, 1921 to 12:00 noon on July 1, 2020?
Topic analysis
First calculate the total number of days from 1922 to 2020, and then subtract the extra days from the
topic code

#include<iostream>

using namespace std;

int yearDay(int year)
{
    
    
	if ((year%4==0&&year%100!=0) || (year%400==0))
	{
    
    
		return 366;
	}
	return 365;
} 

int main()
{
    
    
	int time = 0;
	for(int i = 1922; i <= 2020; i++)
	{
    
    
		time += yearDay(i);
	}
	time -= 22; 
	cout << time*24*60 << endl;
	return 0;
	
}

question answer

52038720

Question 3: Combined Detection (10 points)

Topic description
The new crown epidemic is caused by the new crown virus, which has recently spread in country A. In order to control the epidemic as soon as possible, country A is preparing to test a large number of people for virus nucleic acid.
However, kits for testing are in short supply.
In order to solve this difficulty, scientists have come up with a solution: combined detection. Specimens collected from multiple people (k) are about to be tested in the same kit. If the result is negative, it means that the k people are all negative, and the test of the k people has been completed with one kit. If the result is positive, it means that at least one person is positive, and all the samples of these k people need to be re-tested independently (theoretically, if the k−1 people before the test are all negative, it can be inferred that the kth person is positive, but In practice, this inference will not be used, but k individuals will be tested independently), plus the initial combined testing, a total of k+1 kits are used to complete the testing of k individuals.
Country A estimates that the infection rate of the tested population is about 1, which is evenly distributed. May I ask how much k can save the most kits?
Topic analysis
Here the probability is 1, we might as well set the tester to 100, and then we will discuss the cases where k is divisible by 100 and cannot be divisible
by 100. 100/k+k
is not divisible by 100 100/k+k +1
question code

#include<iostream>

using namespace std;

int main()
{
    
    
	int ans = 0;
	int sum = 0x3f3f3f;
	for(int i = 1; i <= 100; i++){
    
    
		if(100%i==0)
		{
    
    
			if(100/i+i<sum){
    
    
				sum=100/i+i;
				ans = i;
			}
		}
		else
		{
    
    
			if(100/i+1+i<sum) 
			{
    
    
    				sum=100/i+1+i;
    				ans=i;
    		}
		}
	}
	cout << ans <<endl;
} 

question answer

10

Question 4: REPEAT procedure (10 points)

Item description
Total score for this item: 10 points The
attachment prog.txt is a program written in a certain language.
where REPEAT k represents a loop of degree k. The range of loop control is expressed by indentation, and the continuous indentation from the second line is more than the line (the preceding blank is longer) is the content of the loop.
For example the following snippet:

REPEAT 2:
 A = A + 4
  REPEAT 5:
  REPEAT 6:
   A = A + 5
  A = A + 7
 A = A + 8
A = A + 9

The snippet from the row where A = A + 4 is to the row where A = A + 8 is in the first row's loop twice.
The line from REPEAT 6: to the line from A = A + 7 is in the REPEAT 5: loop.
A = A + 5 The actual total number of cycles is 2 × 5 × 6 = 60 times.
After the program is executed, what is the value of A?
Analysis
of the topic It can be seen from the title that REPEAT is a for loop, the number behind is the number of loops, and the range of loop control is expressed by indentation. Then simulate the question and you can
code the question

#include<iostream>

using namespace std;

int main()
{
    
    
	int ans = 0;
	for(int i = 0; i < 2; i++)
	{
    
    
		ans += 4;
		for(int j = 0; j < 5; j++)
		{
    
    
			for(int k = 0; k < 6; k++)
			{
    
    
				ans += 5;
			}
			ans += 7;
		}
		ans += 8;
	}
	ans += 9;
	cout << ans <<endl;
	return 0;
}

question answer

403

Question 5: Matrix (15 points)

Problem Description
Put 1∼2020 in a 2×1010 matrix. It is required that the right side in the same row is larger than the left side, and the lower side in the same column is larger than the upper side. How many options are there in total?
The answer is great, you just need to give the remainder of dividing the number of options by 2020.
topic analysis
topic code


question answer

1340

Question 6: Divisible Sequence (15 points)

Question Description
There is a sequence, the first number of the sequence is n, and each subsequent number is the previous number divisible by 2, please output the positive items in this sequence.
【Input format】The
input line contains an integer n.
[Output format]
Output one line, including multiple integers, and separate adjacent integers with a space to indicate the answer.
[Scale and conventions of evaluation use cases]
For 80% of evaluation use cases, 1≤n≤109.
For all evaluation use cases, 1≤n≤1018.
topic analysis
topic code



Question 7: Decoding (20 points)

topic description
topic analysis
topic code



Question 8: Walk the square (20 points)

Problem Description
There are some two-dimensional lattices on a plane.
The numbering of these points is like the numbering of a two-dimensional array. From top to bottom, they are rows 1 to n, and from left to right are columns 1 to m. Each point can be identified by row number and column number. Express.
Now there is a person standing at row 1, column 1, going to row n and column m. You can only go right or down.
Note that if the row and column numbers are even, you cannot enter this cell.
Ask how many options are there.
【Input format】The
input line contains two integers n, m.
【Output format】
Output an integer to represent the answer.
[Evaluation use case scale and convention]
For all evaluation use cases, 1≤n≤30, 1≤m≤30.
topic analysis
topic code



Question 9: Integer Concatenation (25 points)

Problem Description
Define an array A1,A2,⋅⋅⋅,An of length n. You can choose two numbers Ai and Aj ( i is not equal to j ), and then put Ai and Aj in tandem to form a new integer. For example, 12 and 345 can be spelled 12345 or 34512. Note that swapping the order of Ai and Aj is always treated as 2 spellings, even when Ai=Aj.
Please count how many spellings there are so that the integers spelled out are multiples of K.
【Input format】
The first line contains 2 integers n and K.
The second row contains n integers A1,A2,⋅⋅⋅,An.
[Output format]
An integer represents the answer.
[Scale and conventions of evaluation use cases]
For 30% of evaluation use cases, 1≤n≤1000, 1≤K≤20, 1≤Ai≤104.
For all evaluation cases, 1≤n≤105, 1≤K≤105, 1≤Ai≤109.
topic analysis
topic code



Topic 10: Network Analysis

Topic Description
Xiao Ming is doing a network experiment.
He set up n computers, called nodes, for sending, receiving and storing data.
Initially, all nodes are independent and do not have any connections.
Xiao Ming can connect the two nodes through the network cable, and after the connection, the two nodes can communicate with each other. If two nodes are connected by a network cable, they are called adjacent.
Xiao Ming sometimes tests the network at that time, he will send a message at a certain node, the message will be sent to each adjacent node, and then these nodes will forward to their adjacent nodes, until all the directly or indirectly adjacent nodes. Nodes have received the information. All sending and receiving nodes store the information. A piece of information is only stored once.
Given the process of Xiaoming's connection and testing, please calculate the size of the information stored in each node.
[Input format]
The first line of input contains two integers n, m, which represent the number of nodes and the number of operations respectively. Nodes are
numbered from 1 to n.
The next m lines, each with three integers, represent an operation.
If the operation is 1 ab, it means that the node a and the node b are connected by a network cable. When a=b, it means that a self-loop is connected, which has no substantial impact on the network.
If the operation is 2 pt, it means to send a message of size t on node p.
[Output format]
One line is output, including n integers. The adjacent integers are separated by a space, which in turn indicates
the size of the information stored on node 1 to node n after the above operations are performed.
[Scale and conventions of evaluation use cases]
For 30% of evaluation use cases, 1≤n≤20, 1≤m≤100.
For 50% of the evaluation cases, 1≤n≤100, 1≤m≤1000.
For 70% of the evaluation cases, 1≤n≤1000, 1≤m≤10000.
For all evaluation cases, 1≤n≤10000, 1≤m≤100000, 1≤t≤100.
topic analysis
topic code



Guess you like

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