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 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#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过。
运行结果:
这里写图片描述

你可能感兴趣的:(=====计算几何=====,codeforces,水)