简要题意

给出 \(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. 【多线程那些事儿】如何使用C++写一个线程安全的单例模式?

    如何写一个线程安全的单例模式? 单例模式的简单实现 单例模式大概是流传最为广泛的设计模式之一了.一份简单的实现代码大概是下面这个样子的: class singleton { public: stati ...

  2. el-cascader组件根据最后一级向上找到父级并设置默认值

    vue + elementUI项目中,el-cascader级联选择器使用频率非常高,一些基本使用方法可以参考elementUI官方文档,本文主要研究当接口只返回最后一级id时,如何向上找出所有父级数 ...

  3. 1.pytest入门

    一.pytest单元测试框架 概念:单元测试是指在软件开发中,针对软件的最小单位(函数.方法等)进行正确性的检查测试          单元测试框架是自动化测试框架中的组成部分之一           ...

  4. 7. url反向解析和静态文件

    一.代码中url出现的位置 1.模版[html]中 1.<a href='urk'>超链接点击跳转<a/> 2.<form action='url' method='po ...

  5. 表驱动法在STM32中的应用

    1.概念 所谓表驱动法(Table-Driven Approach)简而言之就是用查表的方法获取数据.此处的"表"通常为数组,但可视为数据库的一种体现.根据字典中的部首检字表查找读 ...

  6. 「浙江理工大学ACM入队200题系列」问题 A: 零基础学C/C++34—— 3个数比较大小(冒泡排序与选择排序算法)

    本题是浙江理工大学ACM入队200题第四套中的A题,同时给出了冒泡排序和选择排序算法 我们先来看一下这题的题面. 由于是比较靠前的题目,这里插一句.各位新ACMer朋友们,请一定要养成仔细耐心看题的习 ...

  7. 【题解】CF1013B And

    题面传送门 解决思路 首先我们可以得出,$ a $ \(\&\) $ x $ \(=\) $ a $ \(\&\) $ x $ \(\&\) $ x $.由此得知,同一个 \( ...

  8. Anaconda环境搭配(Ipython)-获得jupyter notebook(适用Win10)

    关于如何下载anaconda并获得jupyter notebook的随笔. 首先下载anaconda,然后下载完成后,如果是win10系统,则通过下图的放大镜搜索Jupyter Notebook 会有 ...

  9. jquery实现复选框的全选与取消全选功能

    HTML代码 首先创建一个表格: <table class="table table-bordered table-hover"> <tr> <th& ...

  10. 如何查看mysql数据目录位置

    mysql> show global variables like "%datadir%"; +---------------+-----------------+ | Va ...