加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

POJ2641 ZOJ1852 UVA10387 Billiard【反射】

发布时间:2020-12-14 04:23:23 所属栏目:大数据 来源:网络整理
导读:Billiard Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1457 Accepted: 883 Description In a billiard table with horizontal side a inches and vertical side b inches,a ball is launched from the middle of the table. After s 0 seco

Billiard
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1457 Accepted: 883

Description

In a billiard table with horizontal side a inches and vertical side b inches,a ball is launched from the middle of the table. After s > 0 seconds the ball returns to the point from which it was launched,after having made m bounces off the vertical sides and n bounces off the horizontal sides of the table. Find the launching angle A (measured from the horizontal),which will be between 0 and 90 degrees inclusive,and the initial velocity of the ball.
Assume that the collisions with a side are elastic (no energy loss),and thus the velocity component of the ball parallel to each side remains unchanged. Also,assume the ball has a radius of zero. Remember that,unlike pool tables,billiard tables have no pockets.

Input

Input consists of a sequence of lines,each containing five nonnegative integers separated by whitespace. The five numbers are: a,b,s,m,and n,respectively. All numbers are positive integers not greater than 10000.
Input is terminated by a line containing five zeroes.

Output

For each input line except the last,output a line containing two real numbers (accurate to two decimal places) separated by a single space. The first number is the measure of the angle A in degrees and the second is the velocity of the ball measured in inches per second,according to the description above.

Sample Input

100 100 1 1 1
200 100 5 3 4
201 132 48 1900 156
0 0 0 0 0

Sample Output

45.00 141.42
33.69 144.22
3.09 7967.81

Source

Waterloo local 1999.06.19

问题链接:POJ2641 ZOJ1852 UVA10387 Billiard
问题简述:(略)
问题分析
????一个球从台球桌中心发出,给定桌子的长和宽(a,b),经过s时间,长边和宽边上碰撞m和n次,球回到起点。计算球的初速度和方向。
????可以认为,球在水平方向位移为am,垂直方向位移为bn,用时为s。那么,初始运动方向(角度,弧度单位)为angle=atan((bn)/(am)),初速度为v=b*n/s/sin(angle) 。
程序说明
????给出2种程序,都需要注意输出格式,要用"%.2f",不能用"%.2lf",即不可使用高精度的输出格式,否则出现WA,有点没法理解。另外,根据传言,函数atan2()要比函数atan()稳定,也行是对的。
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

 

AC的C++语言程序如下:

/* POJ2641 ZOJ1852 UVA10387 Billiard */

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

const double PI = acos(-1.0);

int main()
{
    double a,n;
    while(~scanf("%lf%lf%lf%lf%lf",&a,&b,&s,&m,&n) && (a || b || s || m || n)) {
        double angle = atan(b * n / (a * m));
        double v = b * n / (s * sin(angle));
        printf("%.2f %.2fn",angle * 180 / PI,v);       // 弧度转角度
    }

    return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读