Codeforces 935 C Fifa and Fafa

935 C

题意:Fifa想用wifi下载足球游戏, 但是Fafa是个流浪狂魔, 所以Fifa想让他的wifi在公寓里尽量覆盖最大的面积,并且不覆盖到Fafa和公寓外的人,fafa的坐标可以在公寓外。

题解:求半径最大的地方就好了, 这个半径最大的位置一定在Fafa和公寓中心的连线上(前提是Fafa不和公寓中心重合且fafa在公寓范围内)。

代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define LL long long
 4 #define fi first
 5 #define se second
 6 #define lson l,m,rt<<1
 7 #define rson m+1,r,rt<<1|1
 8 #define max3(a,b,c) max(a,max(b,c))
 9 const int INF = 0x3f3f3f3f;
10 typedef pair<int,int> pll;
11 int main()
12 {
13     double r, x1, y1, x2, y2;
14     cin >> r >> x1 >> y1 >> x2 >> y2;
15     double l = sqrt(pow(x1-x2,2)+ pow(y1-y2,2));
16     if(l == 0)//重合
17     {
18         printf("%.7f %.7f %.7f", x1+r/2, y1, r/2);
19         return 0;
20     }
21     if(l > r)//在公寓外
22     {
23         printf("%.7f %.7f %.7f", x1, y1, r);
24         return 0;
25     }
26     double Sin = (y1-y2) / l;
27     double Cos = (x1-x2) / l;
28     double ll = (l+r)/2;
29     double ansy = y2 + Sin * ll;
30     double ansx = x2 + Cos * ll;
31     printf("%.7f %.7f %.7f\n",ansx, ansy, ll);
32     return 0;
33 }

原文地址:https://www.cnblogs.com/MingSD/p/8455465.html

时间: 2024-08-30 18:36:56

Codeforces 935 C Fifa and Fafa的相关文章

Codeforces Round #465 &amp;935C. Fifa and Fafa计算几何

传送门 题意:在平面中,有一个圆,有一个点,问能在这个圆中围出最大的圆的圆心坐标和半径.要求这个最大圆不包含这个点. 思路:比较基础的计算几何,要分三种情况,第一种就是这个点在圆外的情况.第二种是点在圆内.第三种是这个点和圆心重合. ac代码 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string> #includ

Codeforces Round #465

A. Fafa and his Company 方法:暴力枚举leader的个数即可 code: 1 /* 2 by skydog 3 */ 4 #include <iostream> 5 #include <cstdio> 6 #include <vector> 7 #include <utility> 8 #include <algorithm> 9 #include <cmath> 10 #include <cstring

Codeforces Round #465 (Div. 2) ABCD

A. Fafa and his Company Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees. Fafa f

CF935D Fafa and Ancient Alphabet 概率dp(递推)

D. Fafa and Ancient Alphabet (简洁题意请往下翻) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ancient Egyptians are known to have used a large set of symbols  to write on the walls of the temple

Codeforces 935E Fafa and Ancient Mathematics(表达式转树 + 树型DP)

题目链接  Codeforces Round #465 (Div. 2) Problem E 题意  给定一个表达式,然后用$P$个加号和$M$个减号填充所有的问号(保证问号个数等于$P + M$) 求可以形成的表达式的最大值. 先把表达式转成一棵树,然后在树上DP. 题目保证了$min(P, M) <= 100$, 为了提高效率,我们选择用少的运算符号作为DP的第二维. 对$P$和$M$的大小关系进行分类讨论. 当$P < M$时, 设$f[i][j]$表示$i$代表的子树里面填$j$个加号

Codeforces 935D Fafa and Ancient Alphabet

题目链接 题意 给定两个\(n\)位的\(m\)进制数\(s1,s2\),所有出现的\(0\)均可等概率地被其他数字替换,求\(s1\gt s2\)的概率. 思路 从高位到低位,根据每一位上相应的\(0\)的个数进行 分类讨论. 计算每一位的时候加上这样一部分答案:比到该位恰能比出大小的情况数. 恰能比出大小意味着:高位全部相同,该位\(s1\gt s2\),低位随便怎么取. 因此,需对两个数目进行记录:1. 前面有多少位是两者皆0:2. 后面还有多少个0没有确定. 另:\(x\)关于\(mod

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多

Codeforces 124A - The number of positions

题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing b

Codeforces 841D Leha and another game about graph - 差分

Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or  - 1. To pass th