GYM 101149 K.Revenge of the Dragon(機智)

Description
一隻火龍要殺死一個人復仇,初始的位置火龍不敢來,但是隻要該人離開初始位置,火龍就會朝着他的方向追殺,火龍一動這個人就會往初始位置跑,火龍始終朝着這個人跑,速度是這個人的兩倍,問這個人的安全區域面積,所謂安全區域就是這個人在這個區域的任一點,都可以在火龍追到他之前跑掉初始位置
Input
四個整數xp,yp,xd,yd分別表示這個人和火龍初始位置的橫縱座標(-1000<=xp,yp,xe,yd<=1000)
Output
輸出安全區域面積
Sample Input
0 0
1 0
Sample Output
0.916297857297023
Solution
硬做這個題推導非常複雜,但是由於已經給出了樣例,不同的初始座標之間只差一個座標系的旋轉和伸縮,面積係數是兩點距離與樣例兩點距離比的平方,拿面積係數乘上樣例輸出即可
Code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define maxn 1111
const double C=0.916297857297023;
int a,b,c,d;
int main()
{
	while(~scanf("%d%d%d%d",&a,&b,&c,&d))
	{
		double ans=(1.0*(c-a)*(c-a)+1.0*(d-b)*(d-b))*C;
		printf("%.10f\n",ans);
	}
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章