Codeforces gym 101149 K 想法

来源:互联网 发布:淘宝买到假货已经下架 编辑:程序博客网 时间:2024/05/17 00:11

Revenge of the Dragon
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

One fairy king hated dragons to death. He gathered a big army and killed every single one of them. But he overlooked a small dragon egg, thinking it was a stone, and the last dragon hatched from this egg soon. Quickly determined who is responsible of the genocide of dragons, the last dragon got angry and destroyed all the kingdom. There was no army to defend from him as it was all spent to annihilate other dragons.

A fairy kingdom is a coordinate plane. The king with the remains of his army took shelter in a palace located in the point . The palace is securely defended, and the dragon can't destroy it. Realized that, the dragon hid in the point , hoping to attack the king when he comes out of the palace. The king soon learned where the dragon is hiding and tries to estimate the danger of the situation.

If the king is out of the palace, the dragon can notice it at any moment and fly towards him from his lair. It will be spotted by the king's guards immediately, and the king will immediately move straight to the palace, uniformly, until he gets safe behind its walls. The dragon is looking for revenge, so every moment of time he uniformly moves straight to the current king's location. The king is quite old, while the dragon is full of strength, so the speed of the king is twice slower than the speed of the dragon. The king wants to estimate to what extent the dragon infringes the freedom of his movements, so he would like to know the area of the safe part of the plane, where he can walk without fears that the dragon can catch him earlier than he reaches the palace.

Input

The first line contains two space-separated integers: xp and yp ( - 1000 ≤ xp, yp ≤  + 1000) — the coordinates of the palace.

The second line contains two space-separated integers: xd and yd ( - 1000 ≤ xd, yd ≤  + 1000) — the coordinates of the dragon's lair.

These two points don't coincide.

Output

Output a single floating-point number — the area of the safe part of the plane. The absolute of relative error must not exceed 10 - 6.

Example
input
0 01 0
output
0.916297857297023

题意:宫殿的坐标  龙的坐标  龙的速度是国王的速度两倍  而且龙只会向国王所在的方向走  现在问有多少面积是安全的

一个点定义是安全的  国王回到宫殿  龙追不上他


题解:这是套路题

想想看  这个题坐标是没意义的  只有龙和宫殿的距离有用

当左边伸展k倍时  所有图形的面积会变成k^2

开始的距离是1

那么答案就是  k^2*样例答案


#include<cstdio>      #include<cstring>     #include<iostream>    #include<algorithm>  #include<vector> #include<cmath>using namespace std;#define pi acos(-1.0)int main(){int a,b;int x,y;cin>>a>>b>>x>>y; int dis=(a-x)*(a-x)+(b-y)*(b-y);printf("%.15f\n",(double)dis*(0.916297857297023));return 0;}


0 0
原创粉丝点击