| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我的代码,一直wa,哪位给看看,谢了!In Reply To:H题是不是有很强的数据呀?自己机器上是对的,可总是WA,郁闷 。 Posted by:y05by at 2006-10-21 18:17:57 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef struct point
{
double x;
double y;
}point;
point pos(double ,double ,char,int,int);
main()
{
int w,l;
double x0,y0,x1,y1,ans=0;
int i;
point p;
while (scanf("%d %d",&w,&l)!=EOF)
{
char direction[1000];
ans=0;
p.x=0;
p.y=0;
scanf("%lf %lf",&x0,&y0);
scanf("%lf %lf",&x1,&y1);
scanf("%s",direction);
// printf("%s\n",direction);
int len=strlen(direction);
//printf("len=%d\n",len);
for (i=0;i<len;i++)
{
p=pos(x0,y0,direction[i],w,l);
x0=p.x;
y0=p.y;
}
ans=sqrt((p.x-x1)*(p.x-x1)+(p.y-y1)*(p.y-y1));
printf("%.4lf\n",ans);
}
}
point pos(double x,double y,char dir,int w,int l)
{
point ans;
if (dir=='F')
{
ans.x=x;
ans.y=-y;
}
if (dir=='L')
{
ans.x=-x;
ans.y=y;
}
if (dir=='B')
{
ans.x=x;
ans.y=2*l-y;
}
if (dir=='R')
{
ans.x=2*w-x;
ans.y=y;
}
return ans;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator