2020 Tenth Blue Bridge Cup Group B match provincial school tournament (C / C ++ group) analysis of the subject after the game summary + + Answers Case

2019 Tenth Blue Bridge Cup Group B match provincial school tournament (C / C ++ group) analysis of the subject after the game summary + + Answers Case

Description of the problem
  in the number of columns a [1], a [2 ], ..., a [n] , if for the subscripts i, j, k satisfies 0 <i <j <k < n + 1 and a [i] <a [j] <a [k] , called a [i], a [j ], a [k] is incremented by a set of triples, a [j] is incremented center triples.
  Given a number of columns, column number to ask how many elements can be incremented center triples.
Input format
  of the first line of the input contains an integer n.
  The second line contains n integers a [1], a [2 ], ..., a [n], separated by a space between adjacent integer representing a given number of columns.
Output format
  output line contains an integer that represents the answer.
Sample input
. 5
. 1 2. 5. 3. 5
sample output
2
sample shows
  a [2] and a [4] may be the center of the triad.
Example agreed with the evaluation scale
  for evaluation by 50% in Example, 2 <= n <= 100,0 <= the number of columns in the <= 1000.
  For the evaluation all use cases, 2 <= n <= the number of columns in 1000,0 <<= = 10000.

#include<iostream>
using namespace std;
const int N=1000;
int main()
{
	int a[N],n,i,sum=0,j,k;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<n-2;i++)
	{
		for(j=i+1;j<n-1;j++)
			{
				for(k=j+1;k<n;k++)
					{
						if(a[i]<a[j] && a[j]<a[k])
						{	
							sum++;
							a[j]=0;
							break;
						}
					}
			}
	}
	cout<<sum<<endl;
	return 0;
}

Problem Description
  Given two positive integers n and m, may I ask integer from 1 to n, the digits of the square and for the total number of m?
  For example, when n = 100, m = 5, 12 and 21 only the sum of the squares of the digits and 5, so the answer is 2.
Input format
  of the first line of input contains two integers n and m, separated by a space.
Output format
  output line contains an integer that represents the answer.
Sample input
100 5
Sample Output
2
Evaluation scale use cases and conventions
  for the use of 40% Example Reviews, 1 <= n <= 1000,1 <= m <= 1000.
  For the evaluation all use cases, 1 <= n <= 1000000,1 <= m <= 1000.

#include <bits/stdc++.h> 
using namespace std;
int main()
{
	int n,m,num=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int a=i,r=0;
		while(a)
		{
			r+=(a%10)*(a%10);
			a/=10;
		}
		if(r==m)num++;
	}
	cout<<num<<endl;
	return 0;
}

Description of the problem
  under normal circumstances, if a word in the first paragraph, the first letter capitalized, followed by lower-case letters.
  Given a word, the word may contain uppercase and lowercase letters, please press the first letter capitalized, followed by lowercase way output.
Input format
  input line contains a word, the word contains only uppercase or lowercase letters.
Output format
  output word form in the first paragraph, the first letter capitalized other letters lowercase.
Sample Input
LanQiao
Sample Output
Lanqiao
Sample Input
cUp
Sample Output
Cup
evaluation scale and conventions used in Example

#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
int main(){
    char c[100];
    while(gets(c)){
        int num=strlen(c);
        //注意非字母的特殊处理
        if(c[0]>='a'&&c[0]<='z')
            cout<<(char)('A'-'a'+c[0]);
        else
            cout<<c[0];
        for(int i=1;i<num;i++){
            if(c[i]>='A'&&c[i]<='Z'){
                cout<<(char)(c[i]-'A'+'a');
            }
            else
                cout<<c[i];
        }
        cout<<endl;
    }
}

Description of the problem
  for a table of n rows and m columns, we can use a spiral manner to form sequentially fill a positive integer, we call the completed form is a helical array.
  For example, a four helix matrix rows and five columns as follows:
  . 1. 5 2. 3 4
  14 15 16. 6. 17
  13 is 18 is. 7. 19 20 is
  12 is 10. 11. 9. 8
input format
  of the first line of input contains two integers n, m, respectively, the coil the number of rows and columns of the matrix.
  The second line contains two integers r, c, represents the row number and column number of requirements.
Output format
  output an integer value representing the matrix elements of the first helical row r column c.
Sample input
. 4. 5
2 2
sample output
15
evaluation scale use cases and conventions
  for evaluation by 30% in Example, 2 <= n, m < = 20.
  For evaluation by 70% in Example, 2 <= n, m < = 100.
  For the evaluation all use cases, 2 <= n, m < = 1000,1 <= r <= n, 1 <= c <= m.

#include <bits/stdc++.h> 
using namespace std;
int main() {
	int m, n, t = 0;
	cin>>m>>n;
	vector<int> a(m*n);
	for (int i = 1; i <= m*n; i++)
		a[i-1]=i;
	vector<vector<int> > b(m, vector<int>(n));
	int level = m / 2 + m % 2;
	for (int i = 0; i < level; i++) 
	{
		for (int j = i; j <= n - 1 - i && t <= m*n - 1; j++)
			b[i][j] = a[t++];
		for (int j = i + 1; j <= m - 2 - i && t <= m*n - 1; j++)
			b[j][n - 1 - i] = a[t++];
		for (int j = n - i - 1; j >= i && t <= m*n - 1; j--)
			b[m - 1 - i][j] = a[t++];
		for (int j = m - 2 - i; j >= i + 1 && t <= m*n - 1; j--)
			b[j][i] = a[t++];
	}
	int xx,yy;
	cin>>xx>>yy;
	cout<<b[xx-1][yy-1]<<endl;
	return 0;
}

Problem Description
  Given a sequence a_1, a_2, ..., a_n. Where a_1 is the largest number, there is no other equal number of a_1.
  For each number a_i starting from the second number, please find the location before a_i and greater than a_i distance a_i last several a_j position. Ij is called the forward distance of a_i.
  For a given sequence of requests from all the forward and numbers.
Input format
  of the first line of the input contains an integer n, the length of the sequence.
  The second line contains n positive integer, for a given sequence.
Output format
  output an integer representing the forward distance and the sequence of all numbers.
Sample input
. 8
. 9. 7. 6 1 2 3 3 5
Sample Output
14
sample shows
  a sequence to the distance from the front of the second item as follows:
  1, 2, 3, 1, 5, 1, 1
  and 14.
Data size and conventions
  for evaluation by 70% in Example, 1 <= n <= 1000 ;
  for reviews all use cases, 1 <= n <= 100000 , a_1 <= 1000000.
  Please note that the answers can be very large, you may need to use long long to save.

#include <iostream>
#include <algorithm>  
#include <iomanip> 
#include <stack>
using namespace std;
typedef long long int ll; 
struct point{
 ll a;
 ll g;
} p[100005];

int main()
{
	stack<ll> s;
	ll n,d[100005],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>p[i].a;
		d[p[i].a]=i;
		p[i].g=1;
		if(s.empty()||p[i].a<s.top())
		{
			s.push(p[i].a);
		}	
		while(p[i].a>s.top())
		{
			p[i].g+=p[d[s.top()]].g;
			s.pop();	
		}
		if(p[i].a<s.top()) s.push(p[i].a);
		ans+=p[i].g;
	}
	cout<<ans-1;
	
	return 0;
}




Problem Description
  Xiao Ming and friends went to the suburbs to plant trees, they brought some well-developed in his laboratory of saplings.
  Xiao Ming and friends a total of n individuals, who have been carefully selected, in a clearing everyone picked a location for tree planting, a total of n. They are going to bring their own seedlings are planted down.
  However, they encountered a problem: some large trees, while others suffer too close position, leading to two trees after planting will go on collision.
  They will tree as a circle whose center is in a position to find them. If intersects the circle corresponding to two trees, while not suitable for two trees planted (tangency unaffected), referred to as two trees conflict.
  Xiao Ming and friends decided to aggregate together, only one part of the tree planting will continue to ensure that the tree did not conflict with each other. They also hope that these trees can cover the area and (area of a circle and) maximum.
Input format
  of the first line of the input contains an integer n, the number, i.e. the number of positions prepared for planting trees.
  Next n lines, each line three integers x, y, r, represents a tree lying on the ground, the ordinate and the radius.
Output format
  output line contains an integer, it can be expressed without conflict area and planting. Since the area of each tree is an integral multiple of pi, output a value (it is an integer) by dividing the circumference of the answer.
Sample input
. 6
. 1. 1 2
. 1 2. 4
. 1 2. 7
. 4. 1 2
. 4. 4 2
. 4. 7 2
sample output
12
evaluation scale and conventions used in Example
  for evaluation by 30% in Example, 1 <= n <= 10 ;
  For evaluation by 60% in Example, 1 <= n <= 20 ;
  for reviews all use cases, 1 <= n <= 30,0 <= x, y <= 1000,1 <= r <= 1000.

题解

考虑DFS+回溯做法。

枚举出长度为 n{n}n 的二进制01串,第 i{i}i 位上的二进制位代表其是否种植。逐一统计出可种植的情况,并以此维护种植面积的最大值即可。
————————————————
版权声明:本文为CSDN博主「专科辣鸡在线丢人」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_42815590/article/details/103544729
Released nine original articles · won praise 13 · views 9519

Guess you like

Origin blog.csdn.net/ABV09876543210/article/details/103492483