# The second phase of the 12th Blue Bridge Cup

2021-01-10 15:34:57 Zhouna

The 12th Blue Bridge Cup simulation （ The second phase ）
1
Problem description
Excuse me at 1 To 2020 in , How many numbers are there 4 Integer multiple , again 6 Integer multiple .
This is a question to fill in the blanks , You just need to work out the results and submit them . The result of this question is an integer , Only fill in the whole number when submitting the answer , Fill in the extra content will not be able to score .

```#include<iostream>
using namespace std;
int main()
{
int n=2020;
int count=0;
for(int i=1;i<=n;i++)
{
if(i%4==0 && i%6==0)
{
cout<<i<<endl;
count++;
}

}
cout<<count;
return 0;
}
```

2
Problem description
Xiao Ming wants to use binary to represent 1 To 10000 All integers of , Different integers are required to be represented by different binary numbers , Excuse me, , In order to express 1 To 10000 All integers of , At least how many bits are needed ？
This is a question to fill in the blanks , You just need to work out the results and submit them . The result of this question is an integer , Only fill in the whole number when submitting the answer , Fill in the extra content will not be able to score .

``` Computer calculator to binary
14
```

3
Problem description
An undirected graph contains 2020 side , If there are no self rings and double edges in the graph , How many nodes does it contain at least ？
This is a question to fill in the blanks , You just need to work out the results and submit them . The result of this question is an integer , Only fill in the whole number when submitting the answer , Fill in the extra content will not be able to score .

```65
n(n-1)/2=2020```

4
Problem description
How many sequences satisfy the following conditions ：
1. The length of the sequence is 5.
2. Every number in the sequence is 1 To 10 Integer between .
3. The following number in the sequence is greater than or equal to the preceding number .
This is a question to fill in the blanks , You just need to work out the results and submit them . The result of this question is an integer , Only fill in the whole number when submitting the answer , Fill in the extra content will not be able to score .

```#include<iostream>
using namespace std;
int main()
{
int count=0,a1,a2,a3,a4,a5;
for(a1=1;a1<=10;a1++)
{
for(a2=a1;a2<=10;a2++)
{

for(a3=a2;a3<=10;a3++)
{
for(a4=a3;a4<=10;a4++)
{
for(a5=a4;a5<=10;a5++)
{
count++;
}
}
}
}
}
cout<<count<<endl;

return 0;
}```

5
Problem description
The distance between two letters is defined as the distance between their positions in the alphabet . for example A and C The distance to 2,L and Q The distance to 5.
For a string , We call the sum of the distances between two characters in a string the internal distance of the string .
for example ：ZOO The inner distance of is 22, among Z and O The distance to 11.
Excuse me, ,LANQIAO What's the internal distance of ？
This is a question to fill in the blanks , You just need to work out the results and submit them . The result of this question is an integer , Only fill in the whole number when submitting the answer , Fill in the extra content will not be able to score .

``` Manual counting L  A  N  Q   I  A  O
12 1  14 17  9  1  15
L A 11
L N 2
L Q 5
L I 3
L A 11
L O 3
A N 13
A Q 16
A I 8
A A 0
A O 14
N Q 3
N I 5
N A 13
N O 1
Q I 8
Q A 16
Q O 2
I A 8
I O 6
A O 14
SUM=162```

6
Problem description
Given the length of the base of a parallelogram l And height h, Find the area of a parallelogram .
Input format
The first line of input contains an integer l, Represents the base length of a parallelogram .
The second line contains an integer h, Represents the height of a parallelogram .
Output format
Output an integer , Represents the area of a parallelogram .（ Tips ： The length and height of the base are integers. The area of a parallelogram is an integer ）
The sample input
2
7
Sample output
14
Data size and engagement
For all profiling use cases ,1 <= l, h <= 100.

```#include<iostream>
using namespace std;
int main()
{
int l,h;
cin>>l>>h;
cout<<l*h<<endl;
}```

7
Problem description
Now the time is a spot b branch , Excuse me, t Minutes later , What time is it ？
Input format
The first line of input contains an integer a.
The second line contains an integer b.
The third line contains an integer t.
Output format
The first line of the output contains an integer , What is the result .
The second line contains an integer , What is the result .
The sample input
3
20
165
Sample output
6
5
The sample input
3
20
175
Sample output
6
15
Data size and engagement
For all profiling use cases ,0 <= a <= 23, 0 <= b <= 59, 0 <= t, t Minutes later, on the same day .

```#include<iostream>
using namespace std;
int main()
{
int a,b,t;
cin>>a>>b>>t;
b+=t;
if(b>=60)
{
a+=b/60;
b%=60;
}
cout<<a<<endl<<b<<endl;
return 0;
}```

8
Problem description
Little blue has a black and white image , from n * m Pixels make up , From top to bottom n That's ok , Each line goes from left to right m Column . Each pixel consists of a 0 To 255 The gray value between represents .
Now? , Xiaolan is ready to blur the image , The method of operation is ：
For each pixel , It's going to center on it 3 * 3 All the pixels in the area （ May be 9 Pixels or less 9 Pixel ） Divide the sum by the number of pixels in this range （ Take off the whole ）, The resulting value is the result of fuzziness .
Please note that each pixel must be summed with the gray value in the original image .
Input format
The first line of input contains two integers n, m.
The first 2 Go to the first place n + 1 Each line contains m It's an integer , Represents the grayscale value of each pixel , The adjacent integers are separated by a space .
Output format
Output n That's ok , Each row m It's an integer , The adjacent integers are separated by spaces , Represents the blurred image .
The sample input
3 4
0 0 0 255
0 0 255 0
0 30 255 255
Sample output
0 42 85 127
5 60 116 170
7 90 132 191
Data size and engagement
For all profiling use cases ,1 <= n, m <= 100.

```#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int a, ans;
int n,m;
cin>>n>>m;
memset(a,-1,sizeof a);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int count=0;
int sum=0;
if(a[i-1][j-1]!=-1)
{
count++;
sum+=a[i-1][j-1];
}
if(a[i-1][j]!=-1)
{
count++;
sum+=a[i-1][j];
}
if(a[i-1][j+1]!=-1)
{
count++;
sum+=a[i-1][j+1];
}
if(a[i][j-1]!=-1)
{
count++;
sum+=a[i][j-1];
}
if(a[i][j]!=-1)
{
count++;
sum+=a[i][j];
}
if(a[i][j+1]!=-1)
{
count++;
sum+=a[i][j+1];
}
if(a[i+1][j-1]!=-1)
{
count++;
sum+=a[i+1][j-1];
}
if(a[i+1][j]!=-1)
{
count++;
sum+=a[i+1][j];
}
if(a[i+1][j+1]!=-1)
{
count++;
sum+=a[i+1][j+1];
}
ans[i][j]=sum/count;
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<ans[i][j]<<" ";
}
cout<<endl;
}
return 0;
}```

9
Problem description
Xiaolan is responsible for the irrigation of the garden .
A garden can be seen as a n That's ok m The grid of columns . A part of the middle is equipped with a water outlet pipe .
Xiaolan can control a button to open all the outlet pipes at the same time , When open , A location with an outlet pipe can be considered irrigated .
Every minute , The water will expand a square in all directions , The expanded grid can be considered to have been irrigated . That is, if a grid is irrigated one minute before , The next minute, the four squares above, below, left and right are irrigated .
Given the location of the garden hose , Excuse me, k Minutes later , How many squares are irrigated ？
Input format
The first line of input contains two integers n, m.
The second line contains an integer t, Indicates the number of outlet pipes .
Next t Line describes the location of the outlet pipe , Among them the first i The row contains two numbers r, c It means the first one r Xing di c There is a drain in the column .
The next line contains an integer k.
Output format
Output an integer , Answer .
The sample input
3 6
2
2 2
3 4
1
Sample output
9
Sample explanation
use 1 It means to irrigate to ,0 It means not irrigated to .
When you turn on the water pipe ：
000000
010000
000100
1 Minutes later ：
010000
111100
011110
share 9 A grid is irrigated .
Data size and engagement
For all profiling use cases ,1 <= n, m <= 100, 1 <= t <= 10, 1 <= k <= 100.

```#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int visited;
int map;
int count=0;
memset(map,-1,sizeof map);
int n,m;
int t;
int r,c;
int k;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
map[i][j]=0;
}
}
cin>>t;
for(int i=1;i<=t;i++)
{
cin>>r>>c;
map[r][c]=1;
}
cin>>k;
while(k--)
{
memset(visited,0,sizeof visited);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(map[i][j]==1 && !visited[i][j])
{
visited[i][j]=1;
visited[i+1][j]=1;
visited[i][j+1]=1;
map[i-1][j]=1;
map[i+1][j]=1;
map[i][j-1]=1;
map[i][j+1]=1;
}
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(map[i][j]==1)
{
count++;
}
}
}
cout<<count<<endl;
return 0;
}```

10
Problem description
Xiao Lan is in a n That's ok m Play a game in the grid of columns .
At the beginning of the , Little blue is standing in the upper left corner of the grid , That is to say 1 Xing di 1 Column .
Little blue can walk on the grid , When walking , If it's in the second r Xing di c Column , He can't go to the bank r The small ones are OK , I can't go to the column number ratio c Small columns . meanwhile , He doesn't walk more than one step in a straight line 3.
for example , If Xiao Lan is in the second place 3 Xing di 5 Column , He can go to the next step 3 Xing di 6 Column 、 The first 3 Xing di 7 Column 、 The first 3 Xing di 8 Column 、 The first 4 Xing di 5 Column 、 The first 4 Xing di 6 Column 、 The first 4 Xing di 7 Column 、 The first 5 Xing di 5 Column 、 The first 5 Xing di 6 Column 、 The first 6 Xing di 5 One of the columns .
Xiaolan will finally come to the third place n Xing di m Column .
In the picture , Some positions have rewards , Go up and get , Some positions have punishment , Go up and be punished . Reward and punishment are finally abstracted into a weight , The reward is positive , The punishment is negative .
Xiao Lan hopes , From 1 Xing di 1 Line goes to the n Xing di m After column , Total weight and maximum . What's the maximum, please ？
Input format
The first line of input contains two integers n, m, Represents the size of the graph .
Next n That's ok , Each row m It's an integer , Represents the weight of each point in a grid graph .
Output format
Output an integer , Represents the maximum weight sum .
The sample input
3 5
-4 -5 -10 -3 1
7 5 -9 3 -10
10 -2 6 -10 -4
Sample output
15
Data size and engagement
about 30% The evaluation case of ,1 <= n, m <= 10;
about 50% The evaluation case of ,1 <= n, m <= 20;
For all profiling use cases ,1 <= n <= 100,-10000 <= A weight <= 10000.

```#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=105,M=105;
int dp[N][M],map[N][M];
int n,m;
int main()
{
memset(map,0,sizeof map);
cin>>n>>m;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
cin>>map[i][j];
}

dp=map;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
dp[i][j]=max(dp[i][j],max(dp[i-1][j]+map[i][j],dp[i][j-1]+map[i][j]));
if(i-2>=0 && j-2>=0)
dp[i][j]=max(dp[i][j],max(dp[i-2][j]+map[i][j],dp[i][j-2]+map[i][j]));
if(i-3>=0 && j-3>=0)
dp[i][j]=max(dp[i][j],max(dp[i-3][j]+map[i][j],dp[i][j-3]+map[i][j]));
}
}
cout<<dp[n][m]+map[n][m]<<endl;
return 0;
}```

https://chowdera.com/2021/01/20210110153402032Y.html