http://codeforces.com/contest/203
这次几乎都是水题,可惜一是晚上我没有网,二是个人读题太慢了
D题贴下代码吧,注意碰到墙或者地面后要反弹,把速度向量取反
#include <iostream>
#include <cstdio>
using namespace std;
#define dcout if(false) cout
const double eps=1e-8;
double a,b,m;
double x0,y0,z0,x,y,z;;
int sign(double a)
{
if(a<eps&a>-eps) return 0;
else if(eps>0) return 1;
return -1;
}
int main()
{
while(cin>>a>>b>>m)
{
cin>>x0>>y0>>z0;
x=a/2,y=m,z=0;
while(1)
{
double t1=max(-x/x0,(a-x)/x0);
double t2=-y/y0;
double t3=max(-z/z0,(b-z)/z0);
double t;
t=min(t1,t3);
t=min(t,t2);
x+=t*x0;
y+=t*y0;
z+=t*z0;
if(!sign(y)) break;
else if(!sign(x)||!sign(x-a)) x0=-x0;
else if(!sign(z)||!sign(z-b)) z0=-z0;
}
//cout<<x<<" "<<y<<" "<<z<<endl;
printf("%.7lf %.7lf\n",x,z);
}
return 0;
}
2万+

被折叠的 条评论
为什么被折叠?



