题目
分析
给定一台球桌的长和宽,运动允许的时间,碰撞长和宽的次数,问要使台球回到原位的打出角度和速度;
其实只是一堆折线,把它铺开,视为直线运动。那么和长宽的碰撞次数和长宽的乘积可以视为在x
、y
坐标的移动距离;
故角度
θ=tanyx
,速度
v=v2x+v2y−−−−−−√=xt2+yt2−−−−−−−√
。
代码
#include <stdio.h>
#include <math.h>
int main(void)
{
int a, b, s, m, n;
while (scanf("%d%d%d%d%d", &a, &b, &s, &m, &n), (a || b || s || m || n))
printf("%.2lf %.2lf\n",
atan((1.0*b*n)/(a*m))*180/(asin(1.0)*2),
sqrt(((1.0*a*m)/s)*((1.0*a*m)/s)+((1.0*b*n)/s)*((1.0*b*n)/s)));
return 0;
}