模拟赛4.18ball

y也一样，当y撞到右边界时，dy=-1，减能量。撞到左边界时，dy又是1，减少能量

#include<bits/stdc++.h>
#define N 110
using namespace std;
int n,m,E,shang,you,xia,zuo,zuoup,youup,youdown,zuodown;
char Map[N][N];
namespace program{
inline void work(){
scanf("%d%d%d",&n,&m,&E);
scanf("%d%d%d%d%d%d%d%d",&shang,&you,&xia,&zuo,&zuoup,&youup,&youdown,&zuodown);
memset(Map,' ',sizeof Map);
for(int i=1;i<n+1;i++)
Map[i][0]=Map[i][m+1]='|';
for(int i=1;i<m+1;i++)
Map[0][i]=Map[n+1][i]='-';
int x=1,y=1,dx=1,dy=1;Map[x][y]='\\';
while(E){
x+=dx;y+=dy;
if((x<1&&y<1)||(x>n&&y>m))break;
if(Map[x][y]=='/'||Map[x][y]=='\\')break;
if(x<1)x+=1,dx=1,E-=shang;//上边界
if(y<1)y+=1,dy=1,E-=zuo;//左边界
if(x>n)x-=1,dx=-1,E-=xia;//下边界
if(y>m)y-=1,dy=-1,E-=you;//右边界
if(E<=0)break;
if(dx==dy)Map[x][y]='\\';//dx==dy则一定是向右下或左上
else Map[x][y]='/';
}
for(int i=0;i<n+2;i++){
for(int j=0;j<m+2;j++)
putchar(Map[i][j]);
puts("");
}
}
}
int main(){
freopen("ball.in","r",stdin);
freopen("ball.out","w",stdout);
program::work();
return 0;
}
/*
5 6 20
1 2 3 4 5 6 7 8

------
|\/\/\ |
|/\/\ \|
|\/\ \/|
|/\ \/\|
|  \/\/|
------

2 21 243
21 18 19 30 31 17 20 24

---------------------
|\  /\  /\  /\  /\ \/\|
| \/  \/  \/  \/  \/\/|
---------------------

*/