简要题意

给出 \(n\) 个向量,求其子集的和的最大模长。

\(1 \leq n \leq 100\)

思路

先说结论:选出的几个向量,一定是极角排序后的某一段(环形)区间。

这个不难感性理解,比如下图:

于是我们对向量极角排序后破环成链,然后暴力枚举区间即可。

时间复杂度 \(O(n^2)\)。

代码

#include <bits/stdc++.h>
#define int long long
using namespace std; int n;
struct Vector{
double x,y;
double polar() const {
return atan2(y,x);
}
double len() const {
return sqrt(x*x+y*y);
}
Vector operator+(const Vector v) const {
return {x+v.x,y+v.y};
}
} vct[205]; double ans; signed main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>vct[i].x>>vct[i].y;
}
sort(vct+1,vct+n+1, [&](Vector x,Vector y){
return x.polar()<y.polar();
});
for(int i=1;i<=n;i++) vct[i+n]=vct[i];
for(int i=1;i<=n;i++){
Vector v={0,0};
for(int j=i;j<(i+n);j++){
v=v+vct[j];
ans=max(ans, v.len());
}
}
cout<<fixed<<setprecision(48)<<ans;
return 0;
}

ABC193F Engines的更多相关文章

  1. HTML5 game engines

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

  2. [Hapi.js] View engines

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

  3. information_schema.engines学习

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

  4. the current differences between MyISAM and InnoDB storage engines

    原文地址:https://stackoverflow.com/questions/47680213/what-are-the-current-differences-between-myisam-an ...

  5. BizDevOps — the true value proposition of workflow engines

    转自:https://blog.bernd-ruecker.com/bizdevops-the-true-value-proposition-of-workflow-engines-f342509ba ...

  6. Easy to use cross-platform 3D engines

    C++ http://gamedev.stackexchange.com/questions/21/easy-to-use-cross-platform-3d-engines-for-c-game-d ...

  7. 数据库存储引擎 show engines 修改引擎

    mysql> show engines; +--------------------+---------+-------------------------------------------- ...

  8. coursera课程Text Retrieval and Search Engines之Week 1 Overview

    Week 1 OverviewHelp Center Week 1 On this page: Instructional Activities Time Goals and Objectives K ...

  9. [翻译]Writing Custom DB Engines 编写定制的DB引擎

    Writing Custom DB Engines  编写定制的DB引擎   FastReport can build reports not only with data sourced from ...

  10. ECMAScript 5 compatibility shims for legacy JavaScript engines

    ECMAScript 5 compatibility shims for legacy JavaScript engines https://github.com/es-shims/es5-shim

随机推荐

  1. 简读《ASP.NET Core技术内幕与项目实战》之3:配置

    特别说明:1.本系列内容主要基于杨中科老师的书籍<ASP.NET Core技术内幕与项目实战>及配套的B站视频视频教程,同时会增加极少部分的小知识点2.本系列教程主要目的是提炼知识点,追求 ...

  2. 故事 --- Linux和UNIX之间的那些爱恨与情仇

    Linux和UNIX具体有哪些关系及区别? UNIX 与 Linux 之间的关系是一个很有意思的话题.在目前主流的服务器端操作系统中,UNIX 诞生于 20 世纪 60 年代末,Windows 诞生于 ...

  3. Eureka Server 实现在线扩容

    Eureka Server 实现在线扩容 作者:Grey 原文地址: 博客园:Eureka Server 实现在线扩容 CSDN:Eureka Server 实现在线扩容 需求 Eureka 是 Sp ...

  4. nrf52——DFU升级OTA升级方式详解(基于SDK开发例程)

    在我们开始前,默认你已经安装好了一些基础工具,如nrfutil,如果你没有安装过请根据官方中文博客去安装好这些基础工具,连接如下:Nordic nRF5 SDK开发环境搭建(nRF51/nRF52芯片 ...

  5. 【YOLOv5】手把手教你使用LabVIEW ONNX Runtime部署 TensorRT加速,实现YOLOv5实时物体识别(含源码)

    前言 上一篇博客给大家介绍了LabVIEW开放神经网络交互工具包[ONNX],今天我们就一起来看一下如何使用LabVIEW开放神经网络交互工具包实现TensorRT加速YOLOv5. 以下是YOLOv ...

  6. C#设置picturebox滚动条来实现查看大图片

    要给PictureBox添加滚动条需要以下步骤:    (1)将picturebox放在panel上:   ( 2)将panel的AutoScroll设置为ture:    (3)将picturebo ...

  7. Vue2 到 Vue3,重温这 5 个常用的 API

    距离Vue3发布已经过去一年多时间了,从Vue2到Vue3是一个不小的升级,包括周边生态等.虽然目前大多数开发者们在使用的仍旧以Vue2为准,但Vue3显然是Vue开发者们未来必须面对的,而且前不久V ...

  8. Web浏览器Linux Shell(shellinabox解决通用区服务器Linux Shell访问很麻烦的问题)

    问题背景 通用区服务器的Linux Shell访问,比较麻烦 需要动态密码(手机上装Token)连跳板机,再用跳板机上的终端工具连Linux Shell 改进方法 使用shellinabox,就能直接 ...

  9. Go语言核心36讲50

    作为拾遗的部分,今天我们来讲讲与Go程序性能分析有关的基础知识. Go语言为程序开发者们提供了丰富的性能分析API,和非常好用的标准工具.这些API主要存在于: runtime/pprof: net/ ...

  10. 【iOS逆向】某车之家sign签名分析

    阅读此文档的过程中遇到任何问题,请关注公众号[移动端Android和iOS开发技术分享]或加QQ群[309580013] 1.目标 分析某车之家sign签名算法的实现 2.操作环境 frida mac ...