链接

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

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

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

  1. #include <iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<algorithm>
  5. #include<stdlib.h>
  6. #include<vector>
  7. #include<cmath>
  8. #include<queue>
  9. #include<set>
  10. using namespace std;
  11. #define N 100000
  12. #define LL long long
  13. #define INF 0xfffffff
  14. const double eps = 1e-;
  15. const double pi = acos(-1.0);
  16. const double inf = ~0u>>;
  17. const double r = 1.0;
  18. const double rd = 3.40;
  19. struct point
  20. {
  21. double x,y,r;
  22. point(double x=,double y=):x(x),y(y){}
  23. }p[N],q[N];
  24. typedef point pointt;
  25. pointt operator -(point a,point b)
  26. {
  27. return point(a.x-b.x,a.y-b.y);
  28. }
  29. double dis(point a)
  30. {
  31. return sqrt(a.x*a.x+a.y*a.y);
  32. }
  33. double dot(point a,point b)
  34. {
  35. return a.x*b.x+a.y*b.y;
  36. }
  37. double angle(point a,point b)
  38. {
  39. return acos(dot(a,b)/dis(a)/dis(b));
  40. }
  41. double angle1(point v)
  42. {
  43. return atan2(v.y,v.x);
  44. }
  45. int dcmp(double x)
  46. {
  47. if(fabs(x)<eps) return ;
  48. return x<?-:;
  49. }
  50. point rotate(point a,double rad)//逆时针旋转
  51. {
  52. return point(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad));
  53. }
  54. bool cmp(point a,point b)
  55. {
  56. return a.x<b.x;
  57. }
  58. int main()
  59. {
  60. int n,i,j;
  61. while(scanf("%d",&n)&&n)
  62. {
  63. for(i = ; i <= n;i++)
  64. {
  65. double x;
  66. scanf("%lf",&x);
  67. p[i] = point(x,);
  68. }
  69. sort(p+,p+n+,cmp);
  70. int tn = n;
  71. double maxz = ;
  72. point tp;
  73. while()
  74. {
  75. int g = ;
  76. for(i = ; i < tn; i++)
  77. {
  78. if(maxz<p[i].y)
  79. {
  80. maxz = p[i].y;
  81. tp = p[i];
  82. }
  83. // if(dcmp(dis(p[i]-p[i+1])-2*r)<0) continue;
  84. // if(dcmp(dis(p[i]-p[i+1])-rd)>0) continue;
  85.  
  86. double b = atan2(fabs(p[i].y-p[i+].y),fabs(p[i].x-p[i+].x));
  87. double d = dis(p[i]-p[i+])/;
  88. double dd = sqrt(-(d*d));
  89. double a = atan2(dd,d);
  90. if(dcmp(a+b-pi/2.0)>) continue;
  91. if(p[i].y<p[i+].y)
  92. {
  93. point pp = point(2.0,);
  94. q[++g] = rotate(pp,a+b);
  95. q[g] = point(q[g].x+p[i].x,q[g].y+p[i].y);
  96. }
  97. else
  98. {
  99. point pp = point(-,);
  100. q[++g] = rotate(pp,-a-b);
  101. q[g] = point(q[g].x+p[i+].x,q[g].y+p[i+].y);
  102. }
  103. }
  104. if(maxz<p[tn].y)
  105. {
  106. maxz = p[tn].y;
  107. tp = p[tn];
  108. }
  109. if(!g) break;
  110. tn = g;
  111. for(i = ; i <= g ; i++)
  112. p[i] = q[i];
  113. }
  114. printf("%.4f %.4f\n",tp.x,tp.y);
  115. }
  116. return ;
  117. }

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. bootstrap/moban191/js/templatemo_custom.js

    (function($) { "use strict"; // Cache selectors var lastId, topMenu = $(".menu-holder ...

  2. 工作上的C/C++相关

    LKSnapShot.h的line127某个类的声明中有: public: typedef TClient<LPeer, ACE_DEV_Connector> _TClient; 这种情况 ...

  3. 有三个线程T1 T2 T3,如何保证他们按顺序执行-转载

    T3先执行,在T3的run中,调用t2.join,让t2执行完成后再执行t3 在T2的run中,调用t1.join,让t1执行完成后再让T2执行 public class Test { // 1.现在 ...

  4. 【转】介绍设置Session失效的几种方法

    转载地址:http://developer.51cto.com/art/201106/269493.htm Session对象是HttpSessionState的一个实例.该类为当前用户会话提供信息, ...

  5. randperm函数

    randperm功能是随机打乱一个数字序列. 语法格式: y = torch.randperm(n) y是把1到n这些数随机打乱得到的一个数字序列. th> torch.randperm() [ ...

  6. Java过滤器应用-对Ajax请求做Session失效判断

    过滤器常用来对Session过期做判断 Layout.js 1.为ajax请求添加标识 2.无论ajax请求成功与否,complete函数终会执行 // 全局Ajax设置, 用于session过期后的 ...

  7. 微软的决心,开发者的信心!惊喜的 Connect(); // 2016

    微软的决心,开发者的信心!惊喜的 Connect(); // 2016   Visual Studio for Mac 2014 年 11 月 13 日,微软宣布 .NET 开源与跨平台.两年后的今天 ...

  8. Duilib动画按钮实现(转载)

    转载:http://blog.csdn.net/cuiguanghui123/article/details/51674218 .h文件 #ifndef __UIBUTTONEX_H__ #defin ...

  9. HTML DOM事件

    HTML DOM事件 1.HTML事件包括: (1)当用户点击鼠标时: (2)当页面已加载时: (3)当图像已加载时: (4)当鼠标移动到元素上时: (5)当输入字段被改变时: (6)当提交HTML表 ...

  10. Linux下Kafka单机安装配置方法(图文)

    Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了普通消息系统的功能,但具有自己独特的设计.这个独特的设计是什么样的呢 介绍 Kafka是一个分布式的.可分区的.可复制的消息系统.它提供了 ...