Why WA on test 24 ??
hello .this is my programm
#include<stdio.h>
//#include<conio.h>
#include<math.h>
//
long energy,armor;
long kol_vrag,sr_energy_vrag,ugol;
long kol_robot,sr_energy_robot;
long ugol_otklona;
//------------------------
void Input(void);
void DG(void);
void DD(void);
void DA(void);
void DP(void);
int Min(const long x,const long y);
void Back(void);
void Atak(void);
//------------------------
void main(void)
{
//clrscr();
//
Input();
//
//getch();
}
//------------------------
void Input(void)
{
char vid;
//
scanf("%ld",&energy);
scanf("%ld",&armor);
//
scanf("%c",&vid);
scanf("%c",&vid);
scanf("%ld",&kol_vrag);
scanf("%ld",&sr_energy_vrag);
scanf("%ld",&ugol);
//
switch(vid){
case 'G':DG();break;
case 'D':DD();break;
case 'A':DA();break;
case 'P':DP();break;
}
}
//
void DG(void)
{
if(!kol_vrag)
printf("STOP");
else
if(abs(ugol)<5)
printf("FIRE %d",Min(20,armor));
else
{
if(ugol>=5)
printf("LEFT %d",Min(100,energy));
else
if(ugol<=(-5))
printf("RIGHT %d",Min(100,energy));
}
}
//
void DD(void)
{
if((20*kol_vrag)>=armor)
Back();
else
DG();
}
//
void DA(void)
{
scanf("%ld",&kol_robot);
scanf("%ld",&sr_energy_robot);
//
if((kol_robot*sr_energy_robot)>(kol_vrag*sr_energy_vrag*3))
Atak();
else
Back();
}
//
void DP(void)
{
scanf("%ld",&ugol_otklona);
//
if(kol_vrag)
DD();
else
if((abs(ugol_otklona)>20)&&(abs(ugol_otklona)<160)){
if( ( (ugol_otklona>20)&&(ugol_otklona<=(90) ))||
((ugol_otklona<=-90)&&(ugol_otklona>-160) ) )
printf("LEFT %d",Min(100,energy));
else
printf("RIGHT %d",Min(100,energy));
}
else
printf("FRONT %d",Min(100,energy));
}
//
int Min(const long x,const long y)
{
int r=x;
//
if(y<r)
r=y;
//
return(r);
}
//
void Back(void)
{
if(abs(ugol)<5)
printf("FIRE %d",Min(20,armor));
else
printf("BACKWARD %d",Min(100,energy));
}
//
void Atak(void)
{
if(abs(ugol)<10)
printf("FIRE %d",Min(20,armor));
else
printf("FRONT %d",Min(100,energy));
}
Re: Why WA on test 24 ??
Test 24: Patrolling, no enemies, angle to the next waypoint <= -160.
Test 27: Patrolling, no enemies, angle to the next waypoint >= 160.
Answer for both tests BACKWARD.