#include<iostream>
//网易笔试题第一题
/*
给定一个棋盘M、N,小球的初始位置Ax、Ay,初始方向V(1左上,2右上,3右下,4左下),时间time,
求最终小球位置
*/
using namespace std;
bool wall(int Ax, int Ay, int M, int N, int &Vx, int &Vy, int &rushcount){
bool rush = false;
if (Ax == 1 && Vx < 0)//上
{
Vx = 1;
rush = true;
rushcount++;
}
else if (Ax == M - 2 && Vx > 0)//下
{
Vx = -1;
rush = true;
rushcount++;
}
if (Ay == 1 && Vy < 0)//左
{
Vy = 1;
rush = true;
rushcount++;
}
else if (Ay == N - 2 && Vy > 0)//右
{
Vy = -1;
rush = true;
rushcount++;
}
return rush;
}
void main5(){
int Lizi, M = 0, N = 0, Ax = 0, Ay = 0, Vx = 0, Vy = 0, V = 0;
cin >> Lizi;
int Mns[1000];
int Axys[1000];
int Vxys[1000];
int Times[1000];
for (int i = 0; i < Lizi; i++){
cin >> M >> N;
Mns[i * 2] = M;
Mns[i * 2 + 1] = N;
cin >> Ax >> Ay;
Axys[i * 2] = Ax - 1;
Axys[i * 2 + 1] = Ay - 1;
cin >> V;
if (V == 0)
{
Vx = -1;
Vy = -1;
}
else if (V == 1)
{
Vx = -1;
Vy = 1;
}
else if (V == 2)
{
Vx = 1;
Vy = 1;
}
else if (V == 3)
{
Vx = 1;
Vy = -1;
}
Vxys[i * 2] = Vx;
Vxys[i * 2 + 1] = Vy;
cin >> Times[i];
}
for (int j = 0; j < Lizi; j++)
{
int Ax1 = Axys[j * 2], Ay1 = Axys[j * 2 + 1];
int Vx1 = Vxys[j * 2], Vy1 = Vxys[j * 2 + 1];
int M1 = Mns[j * 2], N1 = Mns[j * 2 + 1];
int rushcount = 0;
for (int k = 0; k <= Times[j]; k++)
{
bool rush = wall(Ax1, Ay1, M1, N1, Vx1, Vy1, rushcount);
Ax1 += Vx1;
Ay1 += Vy1;
}
cout << rushcount << endl;
}
system("pause");
}