NOIP2017金秋冲刺训练营杯联赛模拟大奖赛第二轮Day1

蒟蒻打的跟狗屎一样,

第一题玄学乱打,真的超讨厌这种题,打得我完全没耐心想其它题了。

然后。。。其它两个题就打暴力了,

纪念一下,被我调到不成样子的第一题。

听说明天很难QAQ

AC代码:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100100;
int n,m,y,x,z;
int pi2[4][2]={1,-1,-1,-1,-1,1,1,1};
struct node{
	int x,y;
};
node s1[N],s2[N],s3[N],s4[N];
int main()
{
	freopen("calc.in","r",stdin);
	freopen("calc.out","w",stdout);
	scanf("%d%d%d%d%d",&m,&n,&y,&x,&z);//n,m,x,y
	m--;n--;
	s1[1].x=0;s1[1].y=m;
	s2[1].x=n;s2[1].y=m;
	s3[1].x=n;s3[1].y=0;
	s4[1].x=1;s4[1].y=0;
	int fang=-1;
	if(x==0){int yu=m-y;if(yu>=z) {printf("%d %d",y+z,x);return 0;}else y=m,z-=yu,fang=1;}
	if(s1[1].y==y){fang=1;}
	if(s2[1].x==x){fang=2;}
	if(s3[1].y==y){fang=3;}
	if(s4[1].x==x){fang=4;}
	int tot=1;
	//xia zuo shang you
	while(fang==-1)
	{
		s1[tot+1].x=s1[tot].x+pi2[0][0];s1[tot+1].y=s1[tot].y+pi2[0][1];
		s2[tot+1].x=s2[tot].x+pi2[1][0];s2[tot+1].y=s2[tot].y+pi2[1][1];
		s3[tot+1].x=s3[tot].x+pi2[2][0];s3[tot+1].y=s3[tot].y+pi2[2][1];
		s4[tot+1].x=s4[tot].x+pi2[3][0];s4[tot+1].y=s4[tot].y+pi2[3][1];
		tot++;
		if(s1[tot].y==y){fang=1;break;}
		if(s2[tot].x==x){fang=2;break;}
		if(s3[tot].y==y){fang=3;break;}
		if(s4[tot].x==x){fang=4;break;}
	}
	//printf("%d\n",fang);
	while(z>=0)
	{
	//	printf("%d\n",fang);
		bool flag=0;
		if(fang==1){int yu=s2[tot].x-x;if(z<=yu){printf("%d %d",y,x+z);return 0;}else x+=yu,z-=yu,fang=2,flag=1;}
		if(fang==2){int yu=y-s3[tot].y;if(z<=yu){printf("%d %d",y-z,x);return 0;}else y-=yu,z-=yu,fang=3,flag=1;}
		if(fang==3){int yu=x-s4[tot].x;if(z<=yu){printf("%d %d",y,x-z);return 0;}else x=s4[tot].x,z-=yu,fang=4,flag=1;}
		s1[tot+1].x=s1[tot].x+pi2[0][0];s1[tot+1].y=s1[tot].y+pi2[0][1];
		if(fang==4){int yu=s1[tot+1].y-y;if(z<=yu){printf("%d %d",y+z,x);return 0;}else y+=yu,z-=yu,fang=1;}
		//printf("!%d %d\n",y,x);
	
		s2[tot+1].x=s2[tot].x+pi2[1][0];s2[tot+1].y=s2[tot].y+pi2[1][1];
		s3[tot+1].x=s3[tot].x+pi2[2][0];s3[tot+1].y=s3[tot].y+pi2[2][1];
		s4[tot+1].x=s4[tot].x+pi2[3][0];s4[tot+1].y=s4[tot].y+pi2[3][1];
		
		tot++;
	}
}
/*
38 27 
7 22 24*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值