您的位置:首页 > 其它

UVA 11880 Ball in a Rectangle(数学+平面几何)

2013-08-23 21:19 316 查看
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

#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-4;

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 == 0 && W == 0 && x == 0 && y == 0 && R == 0 && a == 0 && v == 0 && s == 0) break;
double nx = x + v * cos(PI * a / 180) * s, ny = y + v * sin(PI * a / 180) * s;
L -= R;
W -= R;
while(R >= nx + EPS || nx - EPS >= L) {
if(R >= nx) nx = 2 * R - nx;
//if(nx >= 20 * L) nx = nx - 20 * L;
if(nx >= L) nx = 2 * L - nx;
}
while(R >= ny + EPS || ny - EPS  >= W) {
if(R >= ny) ny = 2 * R - ny;
if(ny >= W) ny = 2 * W - ny;
}
printf("%.2f %.2f\n", nx, ny);
}
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: