链接

problem

给出\(n\)个二元组\((x,y)\)。最初位于原点\((0,0)\),每次可以从这\(n\)个二元组中挑出一个,然后将当前的坐标\((X,Y)\)变为\((X+x,Y+y)\),每个二元组只能被选一次。选出一些二元组,使得按照这些二元组移动后与原点的欧几里得距离最大。求这个距离。

solution

将这\(n\)个二元组看做\(n\)个向量。移动方式遵循平行四边形定则。所以两个向量夹角越小,相加形成的和向量模长就越大。所以将这些向量按照极角排序。选择的向量肯定是一个区间。枚举左右端点,求最大值即可。

code

//@Author: wxyww
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<ctime>
#include<cmath>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
#define pi pair<double,double>
const int N = 110;
ll read() {
ll x = 0,f = 1; char c = getchar();
while(c < '0' || c > '9') {if(c == '-') f = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x * 10 + c - '0',c = getchar();}
return x * f;
}
pi a[N];
bool cmp(const pi &A,const pi &B) {
return atan2(A.second , A.first) < atan2(B.second , B.first);
}
int main() {
int n = read();
for(int i = 0;i < n;++i) a[i].first = read(),a[i].second = read();
sort(a,a + n,cmp);
double ans = 0;
for(int i = 0;i < n;++i) {
double X = a[i].first,Y = a[i].second;
ans = max(ans,X * X + Y * Y);
for(int j = (i + 1) % n;j != i;j = (j + 1) % n) {
X += a[j].first,Y += a[j].second;
ans = max(ans,X * X + Y * Y);
}
}
printf("%.10lf",sqrt(ans));
return 0;
}

AtCoder Beginner Contest 139F Engines的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  7. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  8. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

随机推荐

  1. 详解C++ STL map 容器

    详解C++ STL map 容器 本篇随笔简单讲解一下\(C++STL\)中的\(map\)容器的使用方法和使用技巧. map容器的概念 \(map\)的英语释义是"地图",但\( ...

  2. win10系统使用Telnet命令时提示“telnet不是内部或外部命令”

    in10系统使用Telnet命令时提示“telnet不是内部或外部命令”问题的处理方案 win10系统使用的过程中很多用户会遇到使用Telnet命令时提示“telnet不是内部或外部命令”的问题,这样 ...

  3. 自己收集的好玩的JS特效(持续更新)

    放到我自己的服务器上了. 网 scale.html 樱花 sakura.html

  4. 《细说PHP》第四版 样章 第二章 PHP的应用与发展 2

    2.2  PHP的应用 任何一种主流的编程语言,几乎都可以开发任何类型的软件.编程语言就是一种开发工具,而选择适合的工具去做适合的事儿,才能体现其应用价值.PHP最主要的应用,就是与数据库交互来开发W ...

  5. F5的作用

    F5 F5的全称是F5-BIG-IP-GTM,是最流行的硬件负载均衡设备,其并发能力达到百万级.F5的主要特性包括: 多链路的负载均衡和冗余 可以接入多条ISP链路,在链路之间实现负载均衡和高可用. ...

  6. [转]Apache Doris资料汇总

    参考资料 https://www.toutiao.com/i6709706901770207748/?tt_from=weixin&utm_campaign=client_share& ...

  7. node-sass安装失败处理办法

    参考: https://npm.taobao.org/mirrors https://lzw.me/a/node-sass-install-helper.html 设置环境变量安装 SASS_BINA ...

  8. KiRaiseException函数逆向

    KiRaiseException函数是记录异常的最后一步,在这之后紧接着就调用KiDispatchException分发异常. 我们在逆向前,先看一下书中的介绍: 1. 概念认知: KiRaiseEx ...

  9. 创建WPF项目

    参考: https://www.cnblogs.com/yhcao/p/6237611.html https://mahapps.com/guides/reporting-issues.html ht ...

  10. 用Python程序批量删除excel里面的图片

    前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: Rhinoceros PS:如有需要Python学习资料的小伙伴可以 ...