A - Engines Atcoder 4900
题目大意: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的更多相关文章
- AtCoder Beginner Contest 139F Engines
链接 problem 给出\(n\)个二元组\((x,y)\).最初位于原点\((0,0)\),每次可以从这\(n\)个二元组中挑出一个,然后将当前的坐标\((X,Y)\)变为\((X+x,Y+y)\ ...
- 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 ...
- HTML5 game engines
The following are few examples of game engines implemented with HTML5 and JavaScript: Construct 2: O ...
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识
链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...
- [Hapi.js] View engines
View engines, or template engines, allow you to maintain a clean separation between your presentatio ...
- information_schema.engines学习
当前mysql实例的存储引擎信息可以从information_schema.engines 中查询到 例子: mysql> select * from information_schema.en ...
- AtCoder Regular Contest 082
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...
- AtCoder Regular Contest 069 D
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...
随机推荐
- JSP(二)----指令,注释,内置对象
## JSP 1.指令 * 作用:用于配置JSP页面,导入资源文件 * 格式: <%@ 指令名称 属性名1=属性值1 属性名2=属性值2 %> <%@ page con ...
- Java井字棋游戏
试着写了一个井字棋游戏,希望各位能给予一些宝贵的建议. 一.棋盘类 package 井字棋游戏; public class ChessBoard { private int number; Perso ...
- SpringMVC常见面试题总结(超详细回答)
SpringMVC常见面试题总结(超详细回答) 1.什么是Spring MVC ?简单介绍下你对springMVC的理解? Spring MVC是一个基于Java的实现了MVC设计模式的请求驱动类型的 ...
- 不再忍受龟速 Github,你也可以试试在云开发上部署个人博客!
Hexo 是被大家广泛使用的静态博客系统, 除了在 Github Pages 部署以外,现在你有了一个新的选择,那就是使用云开发静态网站功能来部署啦! 云开发(CloudBase)是一款云端一体化的产 ...
- 给社团同学做的R语言爬虫分享
大家好,给大家做一个关于R语言爬虫的分享,很荣幸也有些惭愧,因为我是一个编程菜鸟,社团里有很多优秀的同学经验比我要丰富的多,这次分享是很初级的,适用于没有接触过爬虫且有一些编程基础的同学,内容主要有以 ...
- springBoot配置文件属性注入
以一个微信公众号开发为例,注入微信appid 1.在application.properites文件中定义属性 #===================微信相关=============#公众号wxp ...
- Docker学习之搭建nginx环境
前言 很久没写随笔了,今天我们来学习一下如何在docker搭建nginx环境吧! 一:下载镜像,使用docker pull拉取最新的nginx镜像 命令:docker pull nginx 查看镜像: ...
- 1014 Waiting in Line (30 分)
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...
- 转载:Docker源码分析(一):Docker架构
原文地址: http://www.infoq.com/cn/articles/docker-source-code-analysis-part1 作者:孙宏亮 1 背景 1.1 Docker简介 D ...
- Windows命令help的基本使用