Input: Standard Input Output: Standard Output

� There is a rectangle on the cartesian plane, with bottom-left corner at (0,0) and top-right corner at (L,W). There is a ball centered at (xy), with radius=R, shown below

At time 0, the ball starts to move along a ray with polar angle a (the angle from positive x-axis to the ray, rotating counter-clockwise). When hitting the rectangle boundary, the reflex angle always equals to the incidence angle. The ball's velocity is always v (i.e. it never changes when hitting the rectangle). Where is the center of the ball at time s?

Input

There will be at most 25 test cases, each contains a line with 8 integers L,W,x,y,R,a,v,s (100L,W109, 1R5, RxL - RRyW - R, 0a < 360, 1vs109), as stated above. The input terminates with LW = x = y = R = a = v = s = 0, which should not be processed.

Output

For each test case, output a line containing two floating-point numbers xy, rounded to two decimal points, indicating that the center of ball will be at (xy) at time s.

题目大意:一个半径为R的圆以一个角度α和恒定速度v在一个L*W的场地中乱撞,撞墙后反射的方向与镜面反射相同。

思路:首先,一个圆在[0,L]、[0,W]里乱撞,相当于一个这个圆的圆心在[R, L-R], [R, W-R]里乱撞。答案也是要圆心,那么只考虑圆心即可。之后,速度是恒定的,横向速度和纵向速度也是不变的,假设场地为无限大,那么我们一开始就可以算出最终坐标(理论上来说极限数据会爆double的精度,但是AC了,我就不管了……要是真WA了我们可以试试long double……)。然后x、y完全可以分开算,他们之间一点影响都木有。于是考虑x,若有一堵墙在L-R处,如果没有墙L我们可以到达xi(超过了L-R),那么有墙我们就会到达2*(L-R) - xi;如果有墙在R,我们可以到达xi(小于R),那么我们就会到达2 * R - xi。不断重复直到xi落在[R, L-R]之间(极限数据这样搞可能会TLE,但是AC了,所以也不管了……)。Y一样搞法,不重复说了。

PS:不要找我要证明我不会,我只能说我觉得这样搞是对的。

代码(19MS):

 #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL; const double PI = acos(-1.0);
const double EPS = 1e-; LL L, W, x, y, R, a, v, s; int main() {
//cout<<cos(PI/2)<<endl;
while(cin>>L>>W>>x>>y>>R>>a>>v>>s) {
if(L == && W == && x == && y == && R == && a == && v == && s == ) break;
double nx = x + v * cos(PI * a / ) * s, ny = y + v * sin(PI * a / ) * s;
L -= R;
W -= R;
while(R >= nx + EPS || nx - EPS >= L) {
if(R >= nx) nx = * R - nx;
//if(nx >= 20 * L) nx = nx - 20 * L;
if(nx >= L) nx = * L - nx;
}
while(R >= ny + EPS || ny - EPS >= W) {
if(R >= ny) ny = * R - ny;
if(ny >= W) ny = * W - ny;
}
printf("%.2f %.2f\n", nx, ny);
}
}

UVA 11880 Ball in a Rectangle(数学+平面几何)的更多相关文章

  1. UVA 12378 Ball Blasting Game 【Manacher回文串】

    Ball Blasting Game Morteza is playing a ball blasting game. In this game there is a chain of differe ...

  2. UVA 10780 Again Prime No Time.(数学)

    给定两个整数m和n,求最大的k使得m^k是n!的约数 对m质因子分解,然后使用勒让德定理求得n!包含的质数p的阶数,min(b[i] / a[i])即为结果k, 若为0无解 #include<c ...

  3. UVA 11582 Colossal Fibonacci Numbers!【数学】

    大一刚开始接触ACM就买了<算法竞赛入门经典>这本书,当时只能看懂前几章,而且题目也没做,粗鄙地以为这本书不适合自己.等到现在快大三了再回过头来看,发现刘老师还是很棒的! 扯远了... 题 ...

  4. UVA 11300 Spreading the Wealth (数学推导 中位数)

    Spreading the Wealth Problem A Communist regime is trying to redistribute wealth in a village. They ...

  5. UVA 10217 A Dinner with Schwarzenegger!!!---数学

    题目链接: https://cn.vjudge.net/problem/UVA-10217 题目大意: 有若干人排队买电影票,如果某个人的生日与排在他前面的某个人的生日相同,那么他讲中奖.中奖的机会只 ...

  6. uva 10828 高斯消元求数学期望

    Back to Kernighan-RitchieInput: Standard Input Output: Standard Output You must have heard the name ...

  7. GCD - Extreme (II) UVA - 11426 欧拉函数_数学推导

    Code: #include<cstdio> using namespace std; const int maxn=4000005; const int R=4000002; const ...

  8. 算法笔记_120:蓝桥杯第六届省赛(Java语言B组部分习题)试题解答

     目录 1 三角形面积 2 立方变自身 3 三羊献瑞 4 九数组分数 5 饮料换购 6 生命之树   前言:以下试题解答代码部分仅供参考,若有不当之处,还请路过的同学提醒一下~ 1 三角形面积 三角形 ...

  9. codeforces 691F F. Couple Cover(组合计数)

    题目链接: F. Couple Cover time limit per test 3 seconds memory limit per test 512 megabytes input standa ...

随机推荐

  1. java流汇总以及使用实例

    流一.基本概念 Java中对文件的操作是以流的方式进行的.流是Java内存中的一组有序数据序列.Java将数据从源(文件.内存.键盘.网络) 读入到内存中,形成了流,然后将这些流还可以写到另外的目的地 ...

  2. js 事件委托 事件代理

    JavaScript高级程序设计上解释:事件委托就是利用事件冒泡,只指定一个事件处理程序,就可以管理某一类型的所有事件. 通过例子类比: 有三个同事预计会在周一收到快递.为签收快递,有两种办法:一是三 ...

  3. Interview Question Overload、Refactoring和Override?

    Overload Overload我们百度翻译知道是超载的意思,不过我们一般称其为重载,在这里我们不纠结于它的翻译,我们来讲讲重载是什么意思,重载的好处.在下面我们以Overload来代表重载(为了记 ...

  4. [Windows]ping itsafe&环境变量

    (1)when you ping a computer from itsafe,the ping command should return the local IP address. (2)wind ...

  5. jsp页面的传值(popup)

    jsp页面与xml文件对应的关系: 例:网页上jsp的url为----purchase_app_btn.do? 对应xml文件下的 <action path="/purchase_ap ...

  6. JDBC编程:获取数据库连接

    JDBC(Java Database Connectivity),即Java数据库连接.通过JDBC编程,可以使Java应用程序和数据库进行交互. JDBC驱动的方式有很多种,我们常用的驱动方式为:本 ...

  7. JQuery中使用FormData异步提交数据和提交文件

    web中数据提交事件是常常发生的,但是大多数情况下我们不希望使用html中的form表单提交,因为form表单提交会中断当前浏览器的操作并且会调到另一个地址(即使这个地址是当前页面),并且会重复加载一 ...

  8. css公共类

    /*iOS弹性滚动*/ .scrolling{ position: absolute; width: 100%; height:100%; overflow-x:hidden; overflow-y: ...

  9. ZooKeeper异常:Error connecting service It is probably not running

    ZooKeeper安装后使用以下命令可以启动成功 bin/zkServer.sh start 但是使用下面命令查看启动状态,则报错误: bin/zkServer.sh status Error con ...

  10. jmeter 插件安装

    1.下载Plugins Manager插件 打开下载插件地址:https://jmeter-plugins.org/ 2.将下载的plugins-manager.jar包复制到Jmeter安装目录,l ...