Lanqiao Cup Eleventh Provincial Competition Simulated C Language

The answer is not yet known, only for reference. Please give some pointers
. 1.
  What is the greatest common divisor of problem description 70044 and 113148?
Answer submission
  This is a question that fills in the blanks with the result. You only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer, and fill in the extra content will not be scored.
Answer
5388

#include<stdio.h>
int main()
{
    
    
	int a=70044,b=113148;
    while(a!=b)
	{
    
    
		if(a>b)
		a=a-b;
		else b=b-a;
		
		}	
	printf("%d",a);
	return 0;
}

2. Problem description
  Among the positive integers not exceeding 19000, what is the number of numbers that are relatively prime to 19000?
Answer submission
  This is a question that fills in the blanks with the result. You only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer, and fill in the extra content will not be scored.
Answer
7200

#include<stdio.h>
int dfs(int a)
{
    
    
	if(a%2!=0&&a%5!=0&&a%19!=0)
	return 1;
	return 0;
	
}

int main()
{
    
    
	int n=19000,i,cns=0;
	for(i=1;i<=19000;i++)
	{
    
    
		if(dfs(i)==1)
		{
    
    
		cns++;
		}
	}
	printf("%d",cns);
	return 0;
	
}

3. Problem description
  How many nodes does a 10-level binary tree contain at most?
  Note that when a binary tree has only one node, it is one level.
Answer submission
  This is a question that fills in the blanks with the result. You only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer, and fill in the extra content will not be scored.
Answer
1023

1+2+4+8+16+32+64+128+256+512

4. Problem description
  What is the decimal number corresponding to the hexadecimal number 1949? Please pay special attention to the given hexadecimal system and the decimal system.
Answer submission
  This is a question that fills in the blanks with the result. You only need to calculate the result and submit it. The result of this question is an integer. Only fill in this integer when submitting the answer, and fill in the extra content will not be scored.
Answer
6473

和等于 16*16*16*1+16*16*9+16*4+9;

Problem description
  Xiaoming dislikes the number 2, including those that contain the number 2 in the digits. If the digits of a number do not contain the number 2, Xiao Ming calls it a clean number.
  How many clean numbers are there among the integers 1 to n?
Input format
  The first line of input contains an integer n.
Output format    The
  output line contains an integer that represents the answer.
Sample input
30
Sample output
18
Evaluation use case scale and convention
  For 40% of evaluation use cases, 1 <= n <= 10000.
  For 80% of the evaluation cases, 1 <= n <= 100000.
  For all measurement cases, 1 <= n <= 1000000.

#include<stdio.h>
int dfs(int a)
{
    
    
	int xb=1,t;
	while(a>=1)
	{
    
    
		t=0;
		t=a%10;
		if(t==2)
		{
    
    
			xb=0;
			return 0;
		}
		a=a/10;
	}
	if(xb)
	return 1;
}

int main()
{
    
    
	long long n,cns=0,i;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
    
    
	   if(dfs(i)==1)
	   {
    
    
	   	cns++;
		   }	
		
	} 
	printf("%lld",cns);
	return 0;
 } 

6. Problem description
  In the sequence a_1, a_2, …, a_n, define the distance between two elements a_i and a_j as |ij|+|a_i-a_j|, that is, the absolute value of the distance of the element subscript plus the difference of the element value, Where |x| represents the absolute value of x.
  Given a sequence of numbers, find out the largest element distance between elements.
Input format
  The first line of input contains an integer n.
  The second line contains n integers a_1, a_2, …, a_n, and adjacent integers are separated by spaces to indicate a given sequence of numbers.
Output format    The
  output line contains an integer that represents the answer.
Example input
5
9 4 2 4 7
Example output
9 The
example shows that
  the distance between a_1 and a_3 is |1-3|+|9-2|=9.
Evaluation use case scale and conventions
  For 50% of evaluation use cases, 2 <= n <= 100, 0 <= number in the series <= 1000.
  For all evaluation cases, 2 <= n <= 1000, 0 <= number in the series <= 10000.
C

#include<stdio.h>
#include<math.h>
int main()
{
    
    
	int n,c;
    scanf("%d",&n);
	int a[n]={
    
    0},i,j;
	for(i=0;i<n;i++)
	{
    
    
		scanf("%d",&a[i]);
	}

	int max=0,sum,h;
	for(i=0;i<n;i++)
	{
    
    
		for(j=i+1;j<n;j++)
		{
    
    
			h=0;sum=0;
			h=fabs(i-j);
			sum=a[i]-a[j];
			sum=fabs(sum+h);
			max=(sum>max?sum:max);
		}
	}
	printf("%d",max);
	return 0;
}

7. The problem is described
  in the sequence a[1], a[2], …, a[n], if a[i] <a[i+1] <a[i+2] <… <a[j] , Then call a[i] to a[j] as an increasing sequence with length j-i+1.
  Given a sequence of numbers, how long is the longest increasing sequence in the sequence.
Input format
  The first line of input contains an integer n.
  The second line contains n integers a[1], a[2], …, a[n]. Adjacent integers are separated by spaces to indicate a given sequence of numbers.
Output format    The
  output line contains an integer that represents the answer.
Sample input
7
5 2 4 1 3 7 2
Sample output
3
Evaluation use case scale and conventions
  For 50% of evaluation use cases, 2 <= n <= 100, 0 <= number in the series <= 1000.
  For all evaluation cases, 2 <= n <= 1000, 0 <= number in the series <= 10000.

#include<stdio.h>
int main()
{
    
    
	int n;
	int a[101];
	int i,j,cns=0,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
    
    
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
    
    
		cns=0;
		for(j=i+1;j<n;j++)
		{
    
    
		   	if(a[j]>a[j-1])
		   	{
    
    
		   		cns++;
			   }
			else break;
		}
		cns=cns+1;
		max=(cns>max?cns:max);
	 } 
	printf("%d",max);
	return 0;
	
}

8. Problem description
  Given a word, please count how many vowels and consonants in this word.
  There are five vowels including a, e, i, o, u, and the others are all consonants.
Input format
  Input one line, containing one word, and the word contains only lowercase English letters.
Output format
  outputs two lines, the first line contains an integer, indicating the number of vowels.
  The second line contains an integer indicating the number of consonants.
Sample input
lanqiao
sample output
4
3
Evaluation use case scale and conventions
  For all evaluation use cases, the number of letters in a word should not exceed 100.

#include<stdio.h>
#include<string.h>
int main() 
{
    
    
	char a[101];
	int i,l,cy=0,cf=0;
	gets(a);
	l=strlen(a);
	for(i=0;i<l;i++)
	{
    
    
		if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
		{
    
    
			cy++;
		}
		else cf++;
	}
	printf("%d\n",cy);
	printf("%d\n",cf);
	return 0;
	
}

9. Problem description
  Xiaoming practices qigong every day, and the most important item in qigong practice is the plum blossom pile.
  Xiao Ming’s plum blossom piles are arranged in n rows and m columns. The distance between two adjacent rows is 1, and the distance between two adjacent columns is also 1.
  Xiaoming is standing on the first row and the first column, and he wants to go to the nth row and the mth column. Xiao Ming has been practicing for a while, and he can now move no more than d in one step (straight line distance).
  Xiao Ming wanted to know how many steps he would have to move to the target without falling off the plum blossom pile.
Input format
  The first line of input contains two integers n, m, which represent the number of rows and columns of the plum blossom pile.
  The second line contains a real number d (contains one decimal at most), indicating the distance Xiao Ming can move in one step.
Output format
  outputs an integer, indicating how many steps Xiao Ming can reach the goal at least.
Sample input
3 4
1.5
Sample output
3
Scale and convention
  of evaluation use cases    For 30% of evaluation use cases, 2 <= n, m <= 20, 1 <= d <= 20.
  For 60% of the evaluation cases, 2 <= n, m <= 100, 1 <= d <= 100.
  For all evaluation cases, 2 <= n, m <= 1000, and 1 <= d <= 100.

#include<stdio.h>
#include<math.h>
int main()
{
    
    
	int n,m,a=1,b=1;
	float d;
	scanf("%d%d",&n,&m);
	scanf("%f",&d);
	float  xb=1.414214;
	int cns=0;
	if(d>xb)
	{
    
    
	   while(a<=n&&b<=m)
	   {
    
    
	   	  a++;b++;
	   	  cns++;
	   }
	}
	else cns=n-a+m-b;
	printf("%d",cns);
	return 0;
	
	
}

10. Problem description
  Xiaoming built a castle with building blocks.
  For convenience, Xiao Ming used a square volume of the same size when building it, which was placed on a grid with n rows and m columns, and each block occupies a small square of the grid.
  Of course, Xiao Ming's castle is not flat, but three-dimensional. Xiao Ming can place blocks on top of other blocks. When the blocks on a square are relatively high, it is a high tower, and when there are no blocks on a square, it is a flat ground.
  Xiao Ming’s castle can be represented by the number of blocks on each square. For example, the following represents a castle.
  9 3 3 1
  3 3 3 0
  0 0 0 0
  This castle has vacant land to the south and east, a large house in the northwest, a tall tower in the northwest corner, and a garage in the northeast corner.
  Now, Gege Witch is coming to destroy Xiao Ming's castle. He casts a spell to flood Xiao Ming's castle.
  If the height of the water is 1, then those blocks close to the ground will be flooded. In the above example, 7 blocks will be flooded.
  If the water height is 2, more blocks will be flooded. In the example above, 13 blocks will be flooded.
  Given Xiao Ming's castle map, how many blocks will be flooded when the water height is 1, 2, 3, …, H.
Input format
  The first line of input contains two integers n, m.
  The next n rows, each with m integers, represent the number of layers of bricks in each position in Xiao Ming's castle.
  Next contains an integer H, which represents the upper limit of the water height.
Output format
  output H lines, each line an integer. The i-th integer represents the number of blocks that are flooded when the water height is i.
Sample input
3 4
9 3 3 1
3 3 3 0
0 0 0 0
10
Sample output
7
13
19
20
21
22
23
24
25
25
Evaluation use case scale and convention
  For 40% of evaluation use cases, 1 <= n, m <= 100, 1 <= H <= 100, the number of building blocks does not exceed 100;
  for 70% of the evaluation cases, 1 <= n, m <= 1000, 1 <= H <= 1000, the number of building blocks does not exceed 1000;
  for all evaluations Use case, 1 <= n, m <= 1000, 1 <= H <= 100000, and the number of blocks does not exceed 1000000000.

#include<stdio.h>
int main()
{
    
    
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n][m];
	int i,j;
	for(i=0;i<n;i++)
	{
    
    
		for(j=0;j<m;j++)
		{
    
    
			scanf("%d",&a[i][j]);
		}
	}
	int h,l;
	scanf("%d",&h);
	int cns=0;
	for(l=1;l<=h;l++)
	{
    
    
	    for(i=0;i<n;i++)
	    {
    
    
		    for(j=0;j<m;j++)
		    {
    
    
		     	if(a[i][j]>=1)
		     	{
    
    
		     		a[i][j]--;
		     		cns++;
				 }
		    } 
     	}
     	printf("%d\n",cns);
	}
	return 0; 
}

Guess you like

Origin blog.csdn.net/qq_46232829/article/details/105600106