6TH HUNAN COLIGIANTE PROGRAMING CONTEST -- PROBLEM D

Since I'm on the road to IELTS,all my articals in this period will be english!

Here's simple problem in the hunan provincial.(uva 11880 Ball in a Rectangle)

Well,the meaning for short , is to calculate the position of a ball in the table after moving a distance,given the original coordinate , the speed and direction it moves.

The solution is to expand the table, knows the total distance and divides it into x-coordinate and  y-coordinate,calculate the position respectively.

Here is the accepted code:

 

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int L,W,x,y,R,a,v,s,k;

double lx,ry,fx,fy;

double pp=3.141592653589793;

long long dis,t;

while(scanf("%d%d%d%d%d%d%d%d",&L,&W,&x,&y,&R,&a,&v,&s) && (L||W))

{

L-=2*R;W-=2*R;

x-=R,y-=R;

dis=(long long)v*s;

ry=dis*sin((double)a/360*2*pp)+y;

lx=dis*cos((double)a/360*2*pp)+x;

 

t=(long long)lx/L;

if(t%2)

{

if(lx<0)

fx=L+(lx-t*L)+R;

else

fx=L-(lx-t*L)+R;

}

else

{

if(lx<0)

fx=-lx+t*L+R;

else

fx=lx-t*L+R;

}

 

t=(long long)ry/W;

if(t%2)

{

if(ry<0)

fy=W+(ry-t*W)+R;

else

fy=W-(ry-t*W)+R;

}

else

{

if(ry<0)

fy=-ry+t*W+R;

else

fy=ry-t*W+R;

}

 

printf("%.2lf %.2lf/n",fx,fy);

}

return 0;

}

 

I didn't AC this problem due to the unaccurate PI-value during the contest,which remained a pity!But as a beginner,I was happy to receive the second prize of Hunan Provincial Collegiate Programming Contest! I would like to give my thanks to my team mates.

2010-11-09/2011-04-10

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值