欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Codeforces Round #512 (Div. 2, based on Technocup 2019 Elimination Round 1)

程序员文章站 2022-05-09 22:18:51
...

传送门:http://codeforces.com/contest/1058

A.水题

#include<bits/stdc++.h>
int main()
{
	int n,flag=0,a;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==1)flag=10;
	}
	if(flag==10)printf("HARD");
	else printf("EASY");
	return 0;
}

B.计算几何:把图画出来分类讨论,把解析式写出来。

#include<bits/stdc++.h>
using namespace std;
#define maxn 100+10
int main()
{
	int d,n,m,x,y;
	scanf("%d%d%d",&n,&d,&m);

	int y1,y2;
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&x,&y);
	if(d<=n-d)
	{
			if(x<=d)
		{
			y1=x+d;
			y2=-x+d;
			//cout<<y1<<y2<<endl;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");
		}
		else if(x<=(n-d)&&x>d)
		{
			y1=x+d;
			y2=x-d;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");	
		}
		else if(x>(n-d)&&x<=n)
		{
			y1=-x-d+2*n;
			y2=x-d;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");	
		}
		else printf("NO");
		printf("\n");
	}
	else 
	{
		if(x<=n-d)
		{
			y1=x+d;
			y2=-x+d;
			//cout<<y1<<y2<<endl;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");
		}
		else if(x<=d&&x>(n-d))
		{
			y1=-x-d+2*n;
			y2=-x+d;
			//cout<<y1<<y2<<endl;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");	
		}
		else if(x>d&&x<=n)
		{
			y1=-x-d+2*n;
			y2=x-d;
			//cout<<y1<<y2<<endl;
			if(y<=y1&&y>=y2)printf("YES");
			else printf("NO");	
		}
		else printf("NO");
		printf("\n");
	}
	}
   return 0;
}

C.暴力搞一搞

#include<bits/stdc++.h>
using namespace std;
int n,i,j,x,y,flag;
char s[102];
int main(){
	scanf("%d%s",&n,s);
	for (i=0;i<n-1;i++)
	{
		x+=s[i]-'0';
		y=0;
		flag=0;
		for (j=i+1;j<n;j++)
		{
			y+=s[j]-'0';
			if (y==x) y=0,flag=1;
			else if (y>x) break;
		}
		if (!y && flag)
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
}

D.