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. Oracle客户端与Toad、plsql developer安装

    (一)oracle client与oracle instant client比较 当我们要使用Toad.plsql developer等工具连接数据库时,首先需要在自己的电脑上安装oracle cli ...

  2. 基于 UIImagePickerController 的拓展封装 - iOS

    基于 UIImagePickerController 的拓展,分别支持调用相机.相册的功能,其中相机可以设置默认调用前后摄像头; 简单对此进行了封装和实现,其中还有很多点可以继续挖掘和优化,该版本具体 ...

  3. c#实现的HTTP服务端

    这次在整理一个服务组件的时候,需要涉及到HTTP的请求,HTTP是应用层,建立在TCP之上的.因此,可以用TCP服务端接收HTTP请求,只需要解析请求内容.HTPP有固定的格式,大家可以直接搜索.网上 ...

  4. Webpack Tapable原理详解

    directory - src - sim ---- 简单的模拟实现 - /.js$/ ---- 使用 代码已上传github, 地址 Detailed Webpack 就像一条生产线, 要经过一系列 ...

  5. Plupload使用API

    Plupload有以下功能和特点: 1.拥有多种上传方式:HTML5.flash.silverlight以及传统的<input type=”file” />.Plupload会自动侦测当前 ...

  6. 用户交互input

    input() 函数 接收到的都是str,如果输入为数字,打印结果想进行运算,此时需要转义.语法:内容=input("提示信息")这里可以直接获取到用户输入的内容. a = inp ...

  7. harbor中碰到的问题

    harbor部署整体比较简单,但是就是这么简单的东西稍微改变点配置文件就会有不小的问题 1.问题1 部署harbor1.6发现web界面删除的镜像在push一遍上去后,镜像大小为0 且无法删除,这个问 ...

  8. springMVC中接收请求参数&&数据转发

    ### 1. 接收请求参数 #### 1.1. [不推荐] 通过HttpServletRequest获取请求参数 假设存在: <form action="handle_login.do ...

  9. Linux系统修改/etc/sysconfig/i18n文件,桌面无法正常显示

    在Windows环境下使用SSH Secure Shell Client登陆VMware Workstation中Linux系统查询hive表时,中文显示乱码:数字和url显示为NULL,网上说: 1 ...

  10. PyCharm入门第一步-——创建并运行第一个Python项目

    创建项目 点击Create New Project 创建项目 输入自己的项目名,点击Create创建 创建文件 右键项目名创建python文件 创建一个HelloPython文件 输入print(&q ...