链接

可以根据反余弦和反正切算出角a和b的值, 然后向量旋转就可以了,图中的状态旋转rotate((2,0),a+b)  反状态把角度反过来,点取(-2,0)即可。

不知道是不是理解错了,题意写着两圆距离》2,《3.4,在求得时候就加了特判,一直WA。。。去了特判就过了。

为了提高精度,可以全化为atan2.

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
const double r = 1.0;
const double rd = 3.40;
struct point
{
double x,y,r;
point(double x=,double y=):x(x),y(y){}
}p[N],q[N];
typedef point pointt;
pointt operator -(point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
double dis(point a)
{
return sqrt(a.x*a.x+a.y*a.y);
}
double dot(point a,point b)
{
return a.x*b.x+a.y*b.y;
}
double angle(point a,point b)
{
return acos(dot(a,b)/dis(a)/dis(b));
}
double angle1(point v)
{
return atan2(v.y,v.x);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
point rotate(point a,double rad)//逆时针旋转
{
return point(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
}
bool cmp(point a,point b)
{
return a.x<b.x;
}
int main()
{
int n,i,j;
while(scanf("%d",&n)&&n)
{
for(i = ; i <= n;i++)
{
double x;
scanf("%lf",&x);
p[i] = point(x,);
}
sort(p+,p+n+,cmp);
int tn = n;
double maxz = ;
point tp;
while()
{
int g = ;
for(i = ; i < tn; i++)
{
if(maxz<p[i].y)
{
maxz = p[i].y;
tp = p[i];
}
// if(dcmp(dis(p[i]-p[i+1])-2*r)<0) continue;
// if(dcmp(dis(p[i]-p[i+1])-rd)>0) continue; double b = atan2(fabs(p[i].y-p[i+].y),fabs(p[i].x-p[i+].x));
double d = dis(p[i]-p[i+])/;
double dd = sqrt(-(d*d));
double a = atan2(dd,d);
if(dcmp(a+b-pi/2.0)>) continue;
if(p[i].y<p[i+].y)
{
point pp = point(2.0,);
q[++g] = rotate(pp,a+b);
q[g] = point(q[g].x+p[i].x,q[g].y+p[i].y);
}
else
{
point pp = point(-,);
q[++g] = rotate(pp,-a-b);
q[g] = point(q[g].x+p[i+].x,q[g].y+p[i+].y);
}
}
if(maxz<p[tn].y)
{
maxz = p[tn].y;
tp = p[tn];
}
if(!g) break;
tn = g;
for(i = ; i <= g ; i++)
p[i] = q[i];
}
printf("%.4f %.4f\n",tp.x,tp.y);
}
return ;
}

poj2194Stacking Cylinders的更多相关文章

  1. acdream:Andrew Stankevich Contest 3:Two Cylinders:数值积分

    Two Cylinders Special JudgeTime Limit: 10000/5000MS (Java/Others)Memory Limit: 128000/64000KB (Java/ ...

  2. zoj 2369 Two Cylinders

    zoj 2369 Two Cylinders 链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2369 题意:已知两个无 ...

  3. sicily 1012. Stacking Cylinders & 1206. Stacking Cylinders

    Time Limit: 1sec    Memory Limit:32MB  Description Cylinders (e.g. oil drums) (of radius 1 foot) are ...

  4. SGU 217. Two Cylinders

    题意:给空间内两根圆柱,求轴线垂直相交时公共部分的体积. 暴力积分即可. ID: Date'n'Time: Name: Task: .Ext: Status: Time: Memory: 158937 ...

  5. UVAlive 7414 Squeeze the Cylinders a,b,c三种步数 搜索+最短路

    题意:给你n个点(n<=50),然后有些点之间会有一条路,路是单向的,每个回合让你走a,b,c三种步数中的任意一种(a,b,c<=100),问你最少需要多少个回合才能保证一定能从1点到达n ...

  6. Linux基础介绍【第九篇】

    服务器添加3块磁盘的体系结构 [root@oldboylinux test]# free -m              total used free shared buffers cached M ...

  7. Linux基础介绍【第四篇】

    Linux文件和目录的属性及权限 命令: [root@oldboy ~]# ls -lhi total 40K 24973 -rw-------. 1 root root 1.1K Dec 10 16 ...

  8. liunx 磁盘管理命令记录

    Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...

  9. Linux系统中的Device Mapper学习

    在linux系统中你使用一些命令时(例如nmon.iostat 如下截图所示),有可能会看到一些名字为dm-xx的设备,那么这些设备到底是什么设备呢,跟磁盘有什么关系呢?以前不了解的时候,我也很纳闷. ...

随机推荐

  1. PHP正则表达式之定界符和原子介绍

    1,正则表达式的定界符. 除了字母.数字和反斜线\以外的任何字符都可以为定界符号,比如 | |.//.{}.!!等等,但是需要注意,如果没有特殊需要,我们都使用正斜线//作为正则表达式的定界符号. 2 ...

  2. 使用 Bootstrap Typeahead 组件

    Bootstrap 中的 Typeahead 组件就是通常所说的自动完成 AutoComplete,功能很强大,但是,使用上并不太方便.这里我们将介绍一下这个组件的使用. 第一,简单使用 首先,最简单 ...

  3. POJ 3903:Stock Exchange(裸LIS + 二分优化)

    http://poj.org/problem?id=3903 Stock Exchange Time Limit: 1000MS   Memory Limit: 65536K Total Submis ...

  4. [xcode]Xcode查找函数(方法)调用及被调用

    参考资料:http://stackoverflow.com/questions/7145045/find-method-references-in-xcode 这个功能有的说是 Find Caller ...

  5. S3c6410 平台 Android系统的Wi-Fi调试记录

    硬件平台:S3c6410 操作系统:Android 网卡芯片:GH381(SDIO接口 sdio8688) 1.SDIO驱动 因为是SDIO接口,所以请先保证mmc驱动(代码在“kernel\driv ...

  6. java 用socket制作一个简易多人聊天室

    代码: 服务器端Server import java.io.*; import java.net.*; import java.util.ArrayList; public class Server{ ...

  7. 我的CSS样式记事本(1)

    文本 行高: line-height 对齐方式: text-align 字符间距: letter-spacing 文本修饰: text-decoration字体 设置字体所有: font 字体类型: ...

  8. angularJS directive详解

    前言 最近学习了下angularjs指令的相关知识,也参考了前人的一些文章,在此总结下. 欢迎批评指出错误的地方. Angularjs指令定义的API AngularJs的指令定义大致如下 angul ...

  9. ie兼容整理

    那里面有东西要长研究 ie bug集合关于如何给各种浏览器打bug,可查询:browser hacks 几篇处理ie问题的帖子,帖子1

  10. 触发onSaveInstanceState和onRestoreInstanceState的时机

    先看Application Fundamentals上的一段话:    Android calls onSaveInstanceState() before the activity becomes ...