UVA 11880 Ball in a Rectangle(数学+平面几何)
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 (x, y), 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 (100
L,W
109, 1
R
5, R
x
L - R, R
y
W - R, 0
a < 360, 1
v, s
109), as stated above. The input terminates with L= W = 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 x, y, rounded to two decimal points, indicating that the center of ball will be at (x, y) 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(数学+平面几何)的更多相关文章
- 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 ...
- UVA 10780 Again Prime No Time.(数学)
给定两个整数m和n,求最大的k使得m^k是n!的约数 对m质因子分解,然后使用勒让德定理求得n!包含的质数p的阶数,min(b[i] / a[i])即为结果k, 若为0无解 #include<c ...
- UVA 11582 Colossal Fibonacci Numbers!【数学】
大一刚开始接触ACM就买了<算法竞赛入门经典>这本书,当时只能看懂前几章,而且题目也没做,粗鄙地以为这本书不适合自己.等到现在快大三了再回过头来看,发现刘老师还是很棒的! 扯远了... 题 ...
- UVA 11300 Spreading the Wealth (数学推导 中位数)
Spreading the Wealth Problem A Communist regime is trying to redistribute wealth in a village. They ...
- UVA 10217 A Dinner with Schwarzenegger!!!---数学
题目链接: https://cn.vjudge.net/problem/UVA-10217 题目大意: 有若干人排队买电影票,如果某个人的生日与排在他前面的某个人的生日相同,那么他讲中奖.中奖的机会只 ...
- uva 10828 高斯消元求数学期望
Back to Kernighan-RitchieInput: Standard Input Output: Standard Output You must have heard the name ...
- GCD - Extreme (II) UVA - 11426 欧拉函数_数学推导
Code: #include<cstdio> using namespace std; const int maxn=4000005; const int R=4000002; const ...
- 算法笔记_120:蓝桥杯第六届省赛(Java语言B组部分习题)试题解答
目录 1 三角形面积 2 立方变自身 3 三羊献瑞 4 九数组分数 5 饮料换购 6 生命之树 前言:以下试题解答代码部分仅供参考,若有不当之处,还请路过的同学提醒一下~ 1 三角形面积 三角形 ...
- codeforces 691F F. Couple Cover(组合计数)
题目链接: F. Couple Cover time limit per test 3 seconds memory limit per test 512 megabytes input standa ...
随机推荐
- android ListView 与GridView 学习总结(五)
ListView的使用总结 基本使用: 步骤:在布局文件中定义一个ListView控件-在活动中获得ListView的实例-获得适配器adapter的实例并且传入三个参数-把适配器对象传递给lis ...
- oracle net manager 数据传输安全
oracle net manager来加密客户端与数据库之间或中间件与 数据库之间的网络传输数据 第一步:开始-->所有程序 -->oracle --> 配置和移植工具 --> ...
- 微信小程序流量主如何开通
2018年7月09日,微信小程序流量主全面开通,开通条件如下: 累计独立访客(UV)不低于1000 # 一共一千个人访问你的小程序就可以申请(不限时间) 有严重违规记录的小程序不予申 ...
- BZOJ1432: [ZJOI2009]Function(找规律)
Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1523 Solved: 1128[Submit][Status][Discuss] Descriptio ...
- mysql数据库关于事务的问题?求解答
表格代码: CREATE TABLE `t_teacher` ( `id` ) NOT NULL AUTO_INCREMENT, `name` ) NOT NULL, `deposit` ) DEFA ...
- Co. - VMware - vSphere
VMware vSphere 组件 VMware vSphere是VMware推出的基于云计算的新一代数据中心虚拟化套件,它由VMware ESXi.VMware vCenter Server.VMw ...
- HTML5—— 你肯定会用到的新知识
HTML5 简介 语义化标签 新增结构标签 表单 多媒体 HTML5 简介 XML是更加严格的语言 是HTML和XHTML的结合 语义化标签 新增的语义化标签 header nav section a ...
- 【Nginx一】Nginx服务器搭建
Nginx服务器搭建 Nginx服务器搭建 下载Nginx源码包 安装Nginx 解压Nginx安装包 安装Nginx依赖 启动Nginx 下载Nginx源码包 官网下载地址 命令:wget http ...
- scrapy框架爬取笔趣阁
笔趣阁是很好爬的网站了,这里简单爬取了全部小说链接和每本的全部章节链接,还想爬取章节内容在biquge.py里在加一个爬取循环,在pipelines.py添加保存函数即可 1 创建一个scrapy项目 ...
- python七类之字符串
字符串 一.关键字:str 字符串是不可变的可迭代的数据类型 二.方法: name = 'alex uwu sir' .title #标题 使首字母大写 只要有特殊字符隔开,才能分别认为是多个单词 ...