toj 4608 Ball in a Rectangle

时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte
总提交: 26 测试通过:16

描述

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?

输入

There will be at most 25 test cases, each contains a line with 8 integers L,W,x,y,R,a,v,s (100≤ \leL,W≤ \le109, 1≤ \leR≤ \le5, R≤ \lex≤ \leL - R, R≤ \ley≤ \leW - R, 0≤ \lea < 360, 1≤ \lev, s≤ \le109), as stated above. The input terminates with L = W = x = y = R = a = v = s = 0, which should not be processed.

输出

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.

样例输入

100 100 80 10 5 90 2 23
110 100 70 10 5 180 1 9999
0 0 0 0 0 0 0 0

样例输出

80.00 56.00
71.00 10.00

//矢量分解
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
double l,w,x,y,r,a,v,s;
int main()
{while(cin>>l>>w>>x>>y>>r>>a>>v>>s){if(!l&&!w&&!x&&!y&&!r&&!a&&!v&&!s) break;l-=2*r;w-=2*r;x-=r;y-=r;//相应坐标也要变换a=a*acos(0.0)/90;double vx=v*cos(a),vy=v*sin(a);double dx=fmod(fmod(vx*s,2*l)+2*l,2*l);//其实包括了两部分,向正方向和向负方向,为了code的方便,把两种情况统一为向正方向。//fmod(vx*s,2*l)如果为负值,说明是向着负方向走i米,也就相当于向着正方向走了(2*l-i)米double dy=fmod(fmod(vy*s,2*w)+2*w,2*w);if(x+dx<=l) x+=dx;//分三种情况讨论else if(x+dx<=2*l) x=l-(x+dx-l);else x=x+dx-2*l;if(y+dy<=w) y+=dy;else if(y+dy<=2*w) y=w-(y+dy-w);else y=y+dy-2*w;printf("%.2lf %.2lf\n",x+r,y+r);}return 0;
}

toj 4608 Ball in a Rectangle相关推荐

  1. matlab——识别图像中的圆形目标

    文章目录 说明 Figure 1 imread函数 imshow函数 Figure 2 rgb2gray函数 graythresh函数 im2bw函数 figure函数 Figure 3 bwarea ...

  2. Flash/Flex学习笔记(38):动量守恒与能量守恒

    动能公式: 动量公式: 动量守恒: 能量守恒: 根据这些规律可以得到下列方程组: 解该方程组,得到下面的公式: 把这二个公式相减,可以得到: 即: 我们也经常利用这个公式简化运算 基本的动量守恒演示: ...

  3. Flash/Flex学习笔记(43):动量守恒与能量守恒

    动能公式: 动量公式: 动量守恒: 能量守恒: 根据这些规律可以得到下列方程组: 解该方程组,得到下面的公式: 把这二个公式相减,可以得到: 即: 我们也经常利用这个公式简化运算 基本的动量守恒演示: ...

  4. 足球视频AI(二)——球员与球的目标检测

    一.基础概念 1.1 识别目标: 1)固定机位的视频中球员逐帧识别 2)固定机位的视频中球逐帧识别 3)位置换算与记录 1.2 实现思路 1,利用OpenCV的相邻帧差异识别移动物体 2,利用YOLO ...

  5. toj 4612 A Shooting Game

    toj 4612 A Shooting Game 时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte 总提交: 4 测试通过:4 描述 A and B are pl ...

  6. TOJ 1320.Billiard

    题目链接:http://acm.tju.edu.cn/toj/showp1320.html 1320.   Billiard Time Limit: 1.0 Seconds   Memory Limi ...

  7. TOJ 2977.Eight

    题目链接 : http://acm.tju.edu.cn/toj/showp2977.html Description 8-ball is a billiards competition rules. ...

  8. poj 2559 Largest Rectangle in a Histogram 栈

    // poj 2559 Largest Rectangle in a Histogram 栈 // // n个矩形排在一块,不同的高度,让你求最大的矩形的面积(矩形紧挨在一起) // // 这道题用的 ...

  9. LeetCode 笔记系列 18 Maximal Rectangle [学以致用](最大矩形)

    leetcode之Largest Rectangle in Histogram 标签: leetcode面试题最大矩形堆栈单调队列 2016-07-30 13:47 1325人阅读 评论(0) 收藏  ...

最新文章

  1. Nodejs的模块系统以及require的机制
  2. 传递结构体变量解决方案,资料整理一
  3. php 处理html,PHP解析HTML代码
  4. Flutter 填坑之 表单数据哪里去了?
  5. DotNetCore 3.0 助力 WPF本地化
  6. select选择框必输校验_轮子这么多,我们为什么选择自研NewSQL
  7. Elasticsearch 数据搜索篇
  8. Tomcat 学习过程4
  9. wps怎么写分段函数_连Excel都做不到!WPS这几项真香功能你用过吗
  10. C++总结:static_cast ,reinterpret_cast
  11. python之logging模块简单用法
  12. ReentrantLock深入学习
  13. Jemalloc源码解析_源码剖析
  14. 强烈推荐一个上网以来见过的最好的学习资料网站,全部免费!
  15. Jasmine JavaScript测试 - toBe vs toEqual
  16. 使用Arduino IDE来编写上传STM32以及STM8代码,STM32Duino教程
  17. 核心概念——节点/边/Combo——内置Combo——内置Combo总览
  18. addon游戏_addon_game_mode游戏基本情况设置
  19. fcpx快闪插件推荐,让视频片头片尾更动感
  20. Bia布刷题日记2022/2/17

热门文章

  1. Promise.all 处理error
  2. Mac 系统部署Frp内网穿透服务 实现frpc shell启动脚本启动、停止
  3. eslint 中文解释
  4. 【C语言】用C语言输出一个吃豆人
  5. 使用React Router v4的嵌套路由
  6. mvc中的mvc分别指什么_什么是MVC,它像三明治店吗?
  7. SAS在金融中的应用一
  8. es审计日志_审计系统的一剂良方——事件溯源
  9. docker中的mysql操作
  10. C语言:用单链表实现输入排序