cf gym101061H Robocon Club(简单计算几何 似乎卡精度)

H. Robocon Club

time limit per test2 seconds
memory limit per test64 megabytes

Problem Description
Ahmed thought that robotics is fun so he quit ACM and joined Robocon club ! Unfortunately his first task at the Robocon Club did not go as well as he expected. He was supposed to build a robot that moves in a straight line.

The robot he had built consists of a line segment of length L with a wheel of radius R on each of it’s endpoints. He placed the robot on the x axis, such that the center of the robot was the point (0, 0) , facing the positive y axis (the left and right wheels are located on and respectively).

The two wheels started moving at the same time, however, instead of moving at the same speed, the left wheel rotated at VL revolutions per second(RPS), while the right wheel rotated at VR RPS. both wheels stopped moving after S seconds. Can you help Ahmed locate the center of his robot?

Input
The first line of the input consists of a single integer T , the number of test cases. T lines follow , each describing a test case consisting of five integers L , R , VL , VR , S . indicating the length of the robot , the radius of each wheel , the speed of the left wheel in (RPS), the speed of the right wheel in (RPS) and the duration that the robot had moved , respectively . where (1 ≤ L ≤ 100 ,1 ≤ R ≤ 100 ,0 ≤ VL ≤ 100 ,0 ≤ VR ≤ 100 , 1 ≤ S ≤ 100 ) .

Output
for each test case print two real numbers on a line separated by a space denotes the coordinates of the center of the robot rounded to three decimal places .

Example
input
4
1 1 1 1 1
7 3 2 3 2
10 1 2 1 1
4 3 2 0 1

output
0.000 6.283
-6.589 -13.682
2.865 8.817
4.000 0.000

说是计算几何还不如说是数学题,左右速度相等的时候当然就是x为零,y就是路程,不等的时候就是x轴绕左边或右边某一点为圆心转圈圈,圆心设一个半径R,用速度和L一比就算出来了。

似乎卡精度,虽然我没卡。卡了那位加了eps就过了。

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <set>
#include <algorithm>
#define M 100005
#define mod 1000000007
#define INF -0x3f3f3f3f]
#define PI acos(-1)

using namespace std;

struct node
{
    int id, liter, Max;
};

int main()
{
    int T;
    scanf("%d", &T);
    while(T--)
    {
        double l, r, vl, vr, s, R;
        bool flag = true;
        scanf("%lf %lf %lf %lf %lf", &l, &r, &vl, &vr, &s);
        if(vl > vr)
        {
            double t = vl;
            vl = vr;
            vr = t;
            flag = false;
        }
        if(vl == vr)
        {
            printf("0.000 %.3lf\n", 2. * vl * r * PI * s);
        }
        else
        {
            R = (vl * l) / (vr - vl);
            double de;
            if(!R)
            {
                de = 2. * vr * r * PI / l * s;
                if(flag)
                    printf("%.3lf %.3lf\n", -(l / 2) * (1 - cos(de)), (l / 2) * sin(de));
                else
                    printf("%.3lf %.3lf\n", (l / 2) * (1 - cos(de)), (l / 2) * sin(de));
            }
            else
            {
                de = 2. * vl * r * PI / R * s;
                if(flag)
                    printf("%.3lf %.3lf\n", -(R + l / 2) * (1 - cos(de)), (R + l / 2) * sin(de));
                else
                    printf("%.3lf %.3lf\n", (R + l / 2) * (1 - cos(de)), (R + l / 2) * sin(de));
            }

        }
    }
    return 0;
}

场上1a过。
运行结果:
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值