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 and will release the real questions and answers from previous years. Welcome friends to pay attention to me. Your likes and attention are the best motivation for me! ! !
Update one real question every day, so stay tuned

Lanqiao Cup Past Papers and Detailed Answers


Question 1: Running training (5 points)

Title description
Xiao Ming is going to do a running training.
At the beginning, Xiao Ming is full of physical strength, and his physical strength is calculated as 10,000. If Xiao Ming runs, he loses 600 stamina per minute. If Xiao Ming rests, he will increase his physical strength by 300 per minute. The loss and increase in physical strength change uniformly.
Xiao Ming intends to run for one minute, rest for one minute, run for another minute, and rest for another minute... and so on. If Xiao Ming's physical strength reaches 0 at some point, he will stop exercising.
How long will Xiao Ming stop exercising? To make the answer an integer, please output the answer in seconds. Only fill in the number and not the unit in the answer.
Problem analysis
First find out the loss per second, and then simulate the exercise process of running and rest, you can use the
problem code

#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: Anniversary (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 established on July 23, 1921.
How many minutes are included from 12:00 noon on July 23, 1921 to 12:00 noon on July 1, 2020?
Question analysis
First calculate the total number of days from 1922 to 2020, and then subtract the number of extra days
question 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 test (10 points)

Title description The
new crown epidemic is caused by the new crown virus, which has spread in country A recently. In order to control the epidemic as soon as possible, country A is preparing to test a large number of people for viral nucleic acid.
However, the test kit is in short supply.
In order to solve this difficulty, scientists thought of a way: combined testing. About to put the specimens collected from multiple people (k) into the same kit for testing. If the result is negative, it means that all k people are negative, and the test of 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 persons need to be tested independently again (in theory, if k−1 persons are negative before the test, it can be inferred that the kth person is positive, but In actual operation, this inference will not be used, but k individuals will be tested independently), plus the initial combined test, a total of k+1 kits have been 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. How much can I save the most kits?
Problem analysis
Here the probability is 1, we might as well set the tester to 100, and then classify and discuss the situation where k is divisible by 100 and not divisible
by 100. 100/k+k
can not be 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

Fourth question: REPEAT procedure (10 points)

Title description
Total score for this question: 10 points. The
attached prog.txt is a program written in a certain language.
Among them, REPEAT k represents a cycle of number k. The range of loop control is expressed by indentation, and the content that is continuously indented from the next line more than this line (the previous blank is longer) is the content contained in the loop.
For example, the following fragment:

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

In this fragment, the line from A = A + 4 to the line A = A + 8 is in the first line of the loop twice.
REPEAT 6: The line where 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?
Topic analysis
From the topic, we can see that REPEAT is a for loop. The number after it is the number of loops. The range of loop control is expressed by indentation. Then simulate the question and you can use the
question code

#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)

Title 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?
The answer is big, you only need to give the remainder of the number of plans divided by 2020.
Topic analysis
topic codes


Question answer

1340

Sixth question: Dividing sequence (15 points)

Title description
There is a sequence. The first number of the sequence is n, and each number after it is divided by 2 of the previous number. Please output the items with positive values ​​in this sequence.
[Input format] The
input line contains an integer n.
[Output format]
Output one line, containing multiple integers, separated by a space between adjacent integers to indicate the answer.
[Evaluation use case scale and agreement]
For 80% of evaluation use cases, 1≤n≤109.
For all evaluation use cases, 1≤n≤1018.
Topic analysis
topic codes



Question 7: Decoding (20 points)

Title description
title analysis
title code



Question 8: Going the square (20 points)

Title description
There are some two-dimensional lattices on the plane.
The numbering of these points is like the numbering of a two-dimensional array, from top to bottom from the 1st to the nth row, from left to right from the 1st to the mth column. Each point can be represented by a row number and a column number Said.
Now there is a person standing in row 1, column 1, and going to row n and column m. You can only go right or down.
Note that if the row number and column number are both even numbers, you cannot enter this grid.
Ask how many options are there.
[Input format]
Input a line containing two integers n, m.
[Output format]
Output an integer to indicate the answer.
[Evaluation use case scale and convention]
For all evaluation use cases, 1≤n≤30 and 1≤m≤30.
Topic analysis
topic codes



Question 9: Integer splicing (25 points)

Title description
Define an array A1, A2, ⋅⋅⋅,An with length n. You can choose two numbers Ai and Aj (i is not equal to j), and then put Ai and Aj one after the other into a new integer. For example, 12 and 345 can be combined into 12345 or 34512. Note that the order of exchanging Ai and Aj is always regarded as two spellings, even when Ai=Aj.
Please calculate how many spellings satisfy that the integer spelled out is a multiple of K.
[Input format] The
first line contains 2 integers n and K.
The second line contains n integers A1, A2, ⋅⋅⋅, An.
[Output format]
An integer represents the answer.
[Evaluation use case scale and agreement]
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 codes



Tenth question: network analysis

Title 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 there is no connection.
Xiao Ming can connect two nodes through a network cable, and the two nodes can communicate with each other after the connection. 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 node, and the message will be sent to each neighboring node, and then these nodes will be forwarded to their neighbors until all directly or indirectly neighbors The nodes have all received the information. All sending and receiving nodes will store the information. A message 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 respectively represent the number of nodes and the number of operations. The nodes are
numbered from 1 to n.
In the next m lines, three integers in each line represent an operation.
If the operation is 1 ab, it means that node a and node b are connected by a network cable. When a=b, it means a self-loop is connected, which has no substantial impact on the network.
If the operation is 2 pt, it means that a message of size t is sent on node p.
[Output format]
Output one line, containing n integers, separated by a space between adjacent integers, indicating in turn
the size of the information stored on node 1 to node n after the above operations.
[Evaluation use case scale and agreement]
For 30% of evaluation use cases, 1≤n≤20, 1≤m≤100.
For 50% of the evaluation use cases, 1≤n≤100, 1≤m≤1000.
For 70% of the evaluation cases, 1≤n≤1000, 1≤m≤10000.
For all evaluation use cases, 1≤n≤10000, 1≤m≤100000, 1≤t≤100.
Topic analysis
topic codes



Guess you like

Origin blog.csdn.net/kiwi_berrys/article/details/111461347