Fifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi access point. This access point can be accessed within a range of r meters (this range can be chosen by Fifa) from its position. Fifa must put the access point inside the flat which has a circular shape of radius R. Fifa wants to minimize the area that is not covered by the access point inside the flat without letting Fafa or anyone outside the flat to get access to the internet.
The world is represented as an infinite 2D plane. The flat is centered at (x1, y1) and has radius R and Fafa's laptop is located at (x2, y2), not necessarily inside the flat. Find the position and the radius chosen by Fifa for his access point which minimizes the uncovered area.
The single line of the input contains 5 space-separated integers R, x1, y1, x2, y2 (1 ≤ R ≤ 105, |x1|, |y1|, |x2|, |y2| ≤ 105).
Print three space-separated numbers xap, yap, r where (xap, yap) is the position which Fifa chose for the access point and r is the radius of its range.
Your answer will be considered correct if the radius does not differ from optimal more than 10 - 6 absolutely or relatively, and also the radius you printed can be changed by no more than 10 - 6 (absolutely or relatively) in such a way that all points outside the flat and Fafa's laptop position are outside circle of the access point range.
5 3 3 1 1
3.7677669529663684 3.7677669529663684 3.914213562373095
10 5 5 5 15
5.0 5.0 10.0
#include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef double dl ; #define INF 0x7f const int maxn =1e5+5; #define f(i,l,r) for(int i=l;i<=r;++i) #define g(i,l,r) for(int i=l;i>=r;--i) int main() { freopen("in","r",stdin); dl r,n1,n2,m1,m2; cin>>r>>n1>>m1>>n2>>m2; dl k =sqrt((n2-n1)*(n2-n1) + (m2-m1)*(m2-m1)) ; if(k>=r) { printf("%.16lf %.16lf %.16lf\n",n1,m1,r); } else { dl rr = (k+r)/2; dl t1,t2; if(n1==n2&&m1==m2) printf("%lf %lf %lf\n",n1+r/2,m1,r/2); else { printf("%.16lf %.16lf %.16lf\n",(n1-n2)*rr/k+n2,(m1-m2)*rr/k+m2,rr); } // t1 =sqrt(r*r - (m2-m1)*(m2-m1) ); // t2 =sqrt(r*r - (n2-n1)*(n2-n1) ); /* if(n1>=n2) t1 =sqrt((r*r - (m2-m1)*(m2-m1) + n1*n1 )/4); else t1 =sqrt((r*r - (m2-m1)*(m2-m1) - n1*n1 /4)); if(m1>=m2) t2 =sqrt((r*r - (n2-n1)*(n2-n1) + m1*m1 /4)); else t2=sqrt((r*r - (n2-n1)*(n2-n1) - m1*m1 /4)); */ /* if(n1>=n2) t1 =(t1+n1)/2; else t1 =(t1-n1)/2; if(m1>=m2) t2 =(t2+m1)/2; else t2=(t2-m1)/2; */ // printf("%.16lf %.16lf %.16lf\n",t1,t2,rr); } return 0; }
未来的我一定会感谢现在正在成长的我

本文探讨了Fifa如何在其圆形公寓内放置Wi-Fi接入点以最小化未覆盖区域的问题,同时确保Fafa无法从外部连接到该网络。提供了具体的输入输出示例及解决方案。
1331

被折叠的 条评论
为什么被折叠?



