简要题意

给出 \(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. nginx 通过IP访问项目

    项目新需求,因为是小范围使用的网站,所以不打算配域名,直接通过IP访问当前项目. 环境: LNMP 一键集成环境 当前IP指向的目录 :/home/wwwroot/default/ 但是我的项目.需要 ...

  2. springboot+redis+虚拟机 springboot连接linux虚拟机中的redis服务

    文章目录 1.前提条件:确保虚拟机开启.并且连接到redis 2.新建立一个springboot项目,创建项目时勾选web选项 3.在pom中引入redis依赖 4.在application.prop ...

  3. Vue前端框架基础+Element的使用

    前置内容: AJAX基础+Axios快速入门+JSON使用 目录 1.VUE 1.1 概述 1.2 快速入门 1.3 Vue指令 1.3.1 v-bind & v-model 指令 1.3.2 ...

  4. 试试将.NET7编译为WASM并在Docker上运行

    之前有听到说Docker支持Wasmtime了,刚好.NET7也支持WASM,就带大家来了解一下这个东西,顺便试试它怎么样. 因为WASM(WebAssembly) 一开始是一个给浏览器的技术,比起J ...

  5. mybatis-plus分页失效原因

    mybatis-plus分页失效解决方法 方法一.在启动类添加如下配置 @SpringBootApplication @MapperScan("com.**.mapper") pu ...

  6. 直播CDN调度技术关键挑战与架构设计

    作者:胡济麟 1.背景介绍 1.1 直播业务特点 互联网视频直播是一种消息媒介形态,提供时产时消的内容,经过多年,已经发展出秀场.游戏.电商.体育等多种业务形态.主要特点是:内容实时产生实时消费,对时 ...

  7. Go语言核心36讲01

    你好,我是郝林,今天我分享的内容是:0基础的你,如何开始入门学习Go语言. 1. 你需要遵循怎样的学习路径来学习Go语言? 我们发现,订阅本专栏的同学们都在非常积极的学习和讨论,这让我们非常欣慰,并且 ...

  8. netty系列之:在netty中使用proxy protocol

    目录 简介 netty对proxy protocol协议的支持 HAProxyMessage的编码解码器 netty中proxy protocol的代码示例 总结 简介 我们知道proxy proto ...

  9. i春秋时间

    打开题目就是一段php代码 大致的意思是 ------------------------------------------------------------------------------- ...

  10. c# Winfrom桌面软件自动升级系统

    对于开发桌面应用升级应该是我们第一个要考虑的.一般而言一个项目只有一个客户端,有的时候一个项目可能分好几个客户端,前台客户端,后台客户端.而我在网上找了很久也没有找到可以同时管理多个客户端升级的.所以 ...