UVALive 6748 2D-Solar System
来源:互联网 发布:mac系统ai2018破解码 编辑:程序博客网 时间:2024/05/29 02:44
按照初始位置排序,那么答案必定小于等于相邻两个圆相切的情况。
注意到对于一个圆,令左端离他最近的半径比他大的圆的位置为L,右端离他最近的半径比他大的圆的位置为R,这个圆只会受到L到R这段区间的影响。
所以维护一个半径单调递减的栈即可。
代码:
#include<bits/stdc++.h>using namespace std;const int N = 5e4+5;struct node { int r, a, b; bool operator < (const node& A) const { return b < A.b; }}c[N];double solve(node B, node A) { if(B.a > A.a) return (sqrt(A.r)*sqrt(B.r)*2+B.b-A.b)/(A.a-B.a); return 1e20;}int main() { int n; while(~scanf("%d", &n)) { if(n == 0) break; for(int i = 0; i < n; i++) scanf("%d%d%d", &c[i].r, &c[i].a, &c[i].b); sort(c, c+n); stack<node> S; S.push(c[0]); double ans = 1e20; for(int i = 1; i < n; i++) { while(!S.empty()) { node x = S.top(); ans = min(ans, solve(x, c[i])); if(x.r < c[i].r) S.pop(); else break; } S.push(c[i]); } if(ans == 1e20) puts("Collision-Free System"); else printf("%.2f\n", ans); } return 0;}
阅读全文
0 0
- uvaLive 6748 2D-Solar System
- UVALive 6748 2D-Solar System
- WebGL Solar System
- The Solar System
- Qt下的OpenGL 编程(10)Solar System
- Qt下的OpenGL 编程(10)Solar System
- UVALive - 4356 Fire-Control System
- Tactical Multiple Defense System UVALive
- Project - DX11 Based 3D System (2)
- Shark翻译:2D Toolkit System Overview
- solar 详解
- Solar Tracker
- D、Ranking System
- UVALive 5913 【NEERC 2011 D】 Dictionary Size
- 组队赛(F/D) UVALive
- (转载)D-BUS System Activation
- UvaLive-5713-Qin Shi Huang's National Road System
- UVaLive LA 4356 - Fire-Control System (扫描法 思维)
- Java基础——【习题一】流程控制练习题
- Esp8266 使用 Arduino 开发(一)
- 大整数阶乘
- eclipse中连接SVNbap
- (学习笔记 1)基本概念和术语
- UVALive 6748 2D-Solar System
- Java基础
- 【读书精华分享】《分布式服务框架原理与实践》李林锋(华为PaaS平台架构师)著
- Shiro 教程,Ajax请求拦截跳转页面方案
- 拆点并查集(poj 1182: 食物链)
- Mapreduce是什么
- mybatis一对一关联查询无法查出关联对象的数据的解决
- ZigBee TI ZStack CC2530 3.10 IO口01-输入输出
- 给工具类添加CocoaPods支持