本文共 1608 字,大约阅读时间需要 5 分钟。
Three wizards are doing a experiment. To avoid from bothering, a special magic is set around them. The magic forms a circle, which covers those three wizards, in other words, all of them are inside or on the border of the circle. And due to save the magic power, circle’s area should as smaller as it could be.
Naive and silly “muggles”(who have no talents in magic) should absolutely not get into the circle, nor even on its border, or they will be in danger. Given the position of a muggle, is he safe, or in serious danger? Input The first line has a number T (T <= 10) , indicating the number of test cases. For each test case there are four lines. Three lines come each with two integers x i and y i (|x i, y i| <= 10), indicating the three wizards’ positions. Then a single line with two numbers q x and q y (|q x, q y| <= 10), indicating the muggle’s position. Output For test case X, output "Case #X: " first, then output “Danger” or “Safe”. Sample Input 3 0 0 2 0 1 2 1 -0.50 0
2 0 1 2 1 -0.60 0
3 0 1 1 1 -1.5 Sample Output Case #1: Danger Case #2: Safe Case #3: Safe 根hdu3007一样的思路。 代码如下:#include#define ll long longusing namespace std;struct node{ double x; double y; double r;}p[4];double x,y;inline double dis(node a,node b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int main(){ int t; scanf("%d",&t); int cc=0; while(t--) { for(int i=1;i<=3;i++) scanf("%lf%lf",&p[i].x,&p[i].y); scanf("%lf%lf",&x,&y); node ans;ans=p[1];ans.r=0.0; for(int i=2;i<=3;i++) { if(dis(ans,p[i])<=ans.r) continue; ans=p[i];ans.r=0.0; for(int j=1;j
努力加油a啊,(o)/~
转载地址:http://fztvi.baihongyu.com/