题目大意:n个点,任意几个点组合后得到的点距离原点的最远距离。

题解:极角排序:https://blog.csdn.net/qq_39942341/article/details/79840394

利用极角排序,将这些点看成与原点相作用的向量,然后根据平行四边行法则,两向量之间的角度相差越小,其复合得到的向量的长度越长。

#include<bits/stdc++.h>
using namespace std;
const int N=1E5+;
struct stu{
double a,b;
bool friend operator <(const stu &x,const stu &y){
return atan2(x.b,x.a)<atan2(y.b,y.a);
}
}arr[N];
int nxt[N];
int main(){
int n;
cin>>n;
for(int i=;i<=n;i++) cin>>arr[i].a>>arr[i].b;
for(int i=;i<=n;i++) nxt[i]=i+;
nxt[n]=;
sort(arr+,arr++n);
double ans=;
for(int i=;i<=n;i++){//以每个点为起始点,遍历一圈后回到起始点,同时记录大小
double dx=arr[i].a;
double dy=arr[i].b;
ans=max(ans,arr[i].a*arr[i].a+arr[i].b*arr[i].b); for(int j=nxt[i];j!=i;j=nxt[j]){
dx+=arr[j].a;
dy+=arr[j].b;
ans=max(ans,dx*dx+dy*dy);
}
}
printf("%.15lf\n",sqrt(ans));
return ;
}

A - Engines Atcoder 4900的更多相关文章

  1. AtCoder Beginner Contest 139F Engines

    链接 problem 给出\(n\)个二元组\((x,y)\).最初位于原点\((0,0)\),每次可以从这\(n\)个二元组中挑出一个,然后将当前的坐标\((X,Y)\)变为\((X+x,Y+y)\ ...

  2. HDU 4900 NO ACM NO LIFE(概率+枚举+搜索)(2014 Multi-University Training Contest 4)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4900 Problem Description There is an old country and ...

  3. HTML5 game engines

    The following are few examples of game engines implemented with HTML5 and JavaScript: Construct 2: O ...

  4. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  5. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  6. [Hapi.js] View engines

    View engines, or template engines, allow you to maintain a clean separation between your presentatio ...

  7. information_schema.engines学习

    当前mysql实例的存储引擎信息可以从information_schema.engines 中查询到 例子: mysql> select * from information_schema.en ...

  8. AtCoder Regular Contest 082

    我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...

  9. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

随机推荐

  1. hdu1541树状数组(降维打击)

    题目链接:http://icpc.njust.edu.cn/Problem/Hdu/1541/ 题意是:在二维图上有一系列坐标,其中坐标给出的顺序是:按照y升序排序,如果y值相同则按照x升序排序.这个 ...

  2. php解析配置文件

    php解析配置文件 标签(空格分隔): php .ini格式 ![](https://img2020.cnblogs.com/blog/1458583/202003/1458583-202003301 ...

  3. 【笔记3-31】Python语言基础-元组tuple

    创建元组 my_tuple = () my_tuple1 = 1, 2, 3, 4, 5, 6 元组解包 与元组元素数量一致 a,s,d,f,g,h = my_tuple1 a, b, c, *f = ...

  4. Data Management and Data Management Tools

    Data Management ObjectivesBy the end o this module, you should understand the fundamentals of data m ...

  5. 比CNN表现更好,CV领域全新卷积操作OctConv厉害在哪里?

    CNN卷积神经网络问世以来,在计算机视觉领域备受青睐,与传统的神经网络相比,其参数共享性和平移不变性,使得对于图像的处理十分友好,然而,近日由Facebook AI.新家坡国立大学.360人工智能研究 ...

  6. Linux下段错误(C语言)

    问题描述:在Linux下编程有时会出现段错误的提醒,出现这种错误有可能是因为以下几种原因 1.数组越界:如果在初始化或者接收输入时内容超过了定义好的数组元素个数时会出现段错误,Linux的数组越界检查 ...

  7. iOS 图片的解压缩

    一.图片加载的工作流 概括来说,从磁盘中加载一张图片,并将它显示到屏幕上,中间的主要工作流如下: 假设我们使用 +imageWithContentsOfFile: 方法从磁盘中加载一张图片,此时的图片 ...

  8. centos7环境下安装nginx

    安装所需环境 nginx是C语言开发,在Linux和windows环境上面都可以运行. 1.gcc安装 安装nginx需要将官网下载的代码进行编译,编译依赖gcc环境,如果没有gcc环境,需要先安装g ...

  9. USACO07MAR Face The Right Way G 差分

    题目链接 https://www.luogu.com.cn/problem/P2882 分析 这个题来看的话好像有点难下手,不如再去读一遍题 N遍,发现一句话很重要Each time the mach ...

  10. Javascript/Jquery遇到字符串自动NaN的问题

    结果发现是一个id绑定了两次点击事件.修改之后,问题解决.