POJ 2194 2850 计算几何
题意:
给你了n个圆,让你摞起来,问顶层圆心的坐标
(数据保证间隔两层的圆不会挨着)
思路:
按照题意模拟。
假设我们已经知道了一层两个相邻圆的坐标a:(x1,y1)和b:(x2,y2)
很容易求出来边长是2,2,dis(a,b)的三角形的面积
进而求出来底面所对应的高
找到底面中点
讲a->b 向量旋转90度 乘上高度
就搞出来了坐标
//By SiriusRen
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int cases,n;
typedef double db;
struct P{db x,y;P(){}P(db X,db Y){x=X,y=Y;}}p[][];
bool operator<(P a,P b){return a.x<b.x;}
P operator-(P a,P b){return P(a.x-b.x,a.y-b.y);}
P operator+(P a,P b){return P(a.x+b.x,a.y+b.y);}
db dis(P a){return sqrt(a.x*a.x+a.y*a.y);}
P get(P a,P b){
P c=b-a;db d=dis(c),p=d/+,S=sqrt(p*(p-)*(p-)*(p-d)),h=S/d*;
c.x/=d,c.y/=d;c=P(-c.y*h,c.x*h);
return P((a.x+b.x)/+c.x,(a.y+b.y)/+c.y);
}
int main(){
while(scanf("%d",&n)&&n){
for(int i=;i<=n;i++)scanf("%lf",&p[n][i].x),p[n][i].y=;
sort(p[n]+,p[n]++n);
for(int i=n-;i;i--)
for(int j=;j<=i;j++)
p[i][j]=get(p[i+][j],p[i+][j+]);
printf("%.4lf %.4lf\n",p[][].x,p[][].y);
}
}
POJ 2194 2850 计算几何的更多相关文章
- POJ 1410 Intersection (计算几何)
题目链接:POJ 1410 Description You are to write a program that has to decide whether a given line segment ...
- POJ 1106 Transmitters(计算几何)
题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...
- poj 2507Crossed ladders <计算几何>
链接:http://poj.org/problem?id=2507 题意:哪个直角三角形,一直角边重合, 斜边分别为 X, Y, 两斜边交点高为 C , 求重合的直角边长度~ 思路: 设两个三角形不重 ...
- TOYS - POJ 2318(计算几何,叉积判断)
题目大意:给你一个矩形的左上角和右下角的坐标,然后这个矩形有 N 个隔板分割成 N+1 个区域,下面有 M 组坐标,求出来每个区域包含的坐标数. 分析:做的第一道计算几何题目....使用叉积判断方 ...
- POJ 1654 Area 计算几何
#include<stdio.h> #include<string.h> #include<iostream> #include<math.h> usi ...
- A - TOYS(POJ - 2318) 计算几何的一道基础题
Calculate the number of toys that land in each bin of a partitioned toy box. 计算每一个玩具箱里面玩具的数量 Mom and ...
- POJ 2254 Globetrotter (计算几何 - 球面最短距离)
题目链接:POJ 2254 Description As a member of an ACM programming team you'll soon find yourself always tr ...
- poj 2318 TOYS(计算几何 点与线段的关系)
TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12015 Accepted: 5792 Description ...
- POJ 3304 Segments(计算几何)
意甲冠军:给出的一些段的.问:能否找到一条直线,通过所有的行 思维:假设一条直线的存在,所以必须有该过两点的线,然后列举两点,然后推断是否存在与所有的行的交点可以是 代码: #include < ...
随机推荐
- 【bzoj1922】[Sdoi2010]大陆争霸 - STL - dijkstra
信仰斯普林·布拉泽的克里斯国教徒. 幻想历 8012年 3月2日,位于杰森国东部小镇神谕镇的克里斯国教徒发动 起义. 幻想历 8012年 3月7日,神谕镇的起义被杰森国大军以残酷手段镇压. 幻想历 8 ...
- NOIP2015提高组D1T3 斗地主
问一副排n张,n<=23最少打几次打完,数据组数T<=100. 面向数据编程.. 前30分:乱暴力?没有顺子,把单.对子.炸弹.三张.王炸.三带一判一次即可. 前70分:状压,先预处理哪些 ...
- redis可视化界面的操作【二十一】
1.安装 2.linux服务器中开启linux服务 root@qiaozhi:~# cd /usr/local/redis root@qiaozhi:/usr/local/redis# ./bin/ ...
- vimtips阅读记录
__BEGIN__ *vimtips.txt* For Vim version 8.0. ------------------------------------------------------- ...
- Pull方式解析XML文件
package com.pingyijinren.test; import android.content.Intent; import android.os.Handler; import andr ...
- hdu - 1627 Krypton Factor (dfs)
http://acm.hdu.edu.cn/showproblem.php?pid=1627 给定 n 和 L 找出第n个范围在0-L之内的字符串,字符串要求没有相邻的子串是相同的. 按照格式输出. ...
- Android: Mac无法找到Android SDK问题
通过brew cask install android-sdk后,Intellij Idea中设置Android SDK路径失败,解决方法如下: /usr/local/Caskroom/android ...
- 【转】学习JavaScript闭包
原文: http://www.cnblogs.com/Lau7/p/7942100.html#undefined ------------------------------------------- ...
- owncloud
owncloud https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ [root@n1 ~]# rpm -Uvh ius-relea ...
- CentOS 7加强安全性:
CentOS 7加强安全性:1. 更改 root 密码************************************************************************* ...