题目链接:hdu 5476

  今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3、4个小时,我想到一半时发现样例输出是 (√2) π / 2 + 1, 于是就各种 YY,无奈尝试了各种方法还是免不了 wa。。。

  后来在网上发现,那段圆弧其实就和自己插身而过,真的可以说差一点就想到了,无奈到了最后我们几个都精疲力尽了,好像也想不出什么了。看下图:

   就是三角形里的圆弧的长度,设为 Lc ,很容易得出 Lc = | OC | * 2 * ∠O,而 ∠O = ∠ACM,∠ACM可以由 | AM | 与 | CM | 的 atan 值求出,而 | OC | = | CM | / sin(∠O),所以,核心代码就几行而已:  

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. #include<cmath>
  5. using namespace std;
  6.  
  7. struct point {
  8. double x,y;
  9. point() {}
  10. point(double x, double y): x(x), y(y) {}
  11. void read() { scanf("%lf %lf",&x,&y); }
  12. void readint() {
  13. int x,y;
  14. scanf("%d %d",&x,&y);
  15. this->x = x;
  16. this->y = y;
  17. }
  18. point operator + (const point &p2) const {
  19. return point(x + p2.x, y + p2.y);
  20. }
  21. point operator - (const point &p2) const {
  22. return point(x - p2.x, y - p2.y);
  23. }
  24. point operator * (double p) const {
  25. return point(x * p, y * p);
  26. }
  27. point operator / (double p) const {
  28. return point(x / p, y / p);
  29. }
  30. };
  31.  
  32. typedef point Vector;
  33. typedef const point& cpoint;
  34. typedef const Vector& cvector;
  35.  
  36. point operator * (double p, Vector a) {
  37. return a * p;
  38. }
  39.  
  40. double dot(cvector a, cvector b) {
  41. return a.x * b.x + a.y * b.y;
  42. }
  43.  
  44. double length(cvector a) {
  45. return sqrt(dot(a,a));
  46. }
  47.  
  48. double angle(cvector a, cvector b) {
  49. return acos(dot(a,b) / length(a) / length(b));
  50. }
  51.  
  52. double cross(cvector a, cvector b) {
  53. return a.x * b.y - a.y * b.x;
  54. }
  55.  
  56. const double PI = acos(-1.0);
  57.  
  58. int main() {
  59. int t, Case = ;
  60. point a,b,c;
  61. scanf("%d",&t);
  62. while(t--) {
  63. a.readint();
  64. b.readint();
  65. c.readint();
  66. point m = (b + c) / ;
  67. double am = length(m - a), cm = length(m - c);
  68. double angO = atan(am / cm);
  69. double oc = cm / sin(angO);
  70. double ans = oc * * angO + am;
  71. printf("Case #%d: %.4f\n",++Case,ans);
  72. }
  73. return ;
  74. }

  附上证明截图:(刚刚看懂,好强大~~ Orz Orz)

hdu 5476 Explore Track of Point(2015上海网络赛)的更多相关文章

  1. HDU 5476 Explore Track of Point 数学平几

    Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  2. 2015上海网络赛 HDU 5478 Can you find it 数学

    HDU 5478 Can you find it 题意略. 思路:先求出n = 1 时候满足条件的(a,b), 最多只有20W对,然后对每一对进行循环节判断即可 #include <iostre ...

  3. hdu 5475 模拟计算器乘除 (2015上海网赛H题 线段树)

    给出有多少次操作 和MOD 初始值为1 操作1 y 表示乘上y操作2 y 表示除以第 y次操作乘的那个数 线段树的叶子结点i 表示 第i次操作乘的数 将1替换成y遇到操作2 就把第i个结点的值 替换成 ...

  4. 2015上海网络赛 HDU 5475 An easy problem 线段树

    题意就不说了 思路:线段树,维护区间乘积.2操作就将要除的点更新为1. #include<iostream> #include<cstdio> #include<cstr ...

  5. 2015上海网络赛 A Puzzled Elena

    题意:给定一棵树,求这个节点的所有子树中包括他本身与它互质的节点的个数. 解题思路:题利用dfs序+容斥原理+前缀和性质解决.题目中要求每个结点,和多少个它的子结点互素.如果每次为了求一个点去跑一遍d ...

  6. 2015北京网络赛 D-The Celebration of Rabbits 动归+FWT

    2015北京网络赛 D-The Celebration of Rabbits 题意: 给定四个正整数n, m, L, R (1≤n,m,L,R≤1000). 设a为一个长度为2n+1的序列. 设f(x ...

  7. 2015北京网络赛 J Scores bitset+分块

    2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...

  8. 2015北京网络赛 Couple Trees 倍增算法

    2015北京网络赛 Couple Trees 题意:两棵树,求不同树上两个节点的最近公共祖先 思路:比赛时看过的队伍不是很多,没有仔细想.今天补题才发现有个 倍增算法,自己竟然不知道.  解法来自 q ...

  9. ACM学习历程—HDU5476 Explore Track of Point(平面几何)(2015上海网赛09题)

    Problem Description In Geometry, the problem of track is very interesting. Because in some cases, th ...

随机推荐

  1. 关于android中Bundle的使用

      1.Android using Bundle for sharing variables 注:android中使用Bundle来共享变量,下例中Activity1和Activity2通过bundl ...

  2. hasOwnproperty详细总结

    hasOwnProperty:是用来判断一个对象是否有你给出名称的属性或对象.不过需要注意的是,此方法无法检查该对象的原型链中是否具有该属性,该属性必须是对象本身的一个成员. isPrototypeO ...

  3. Socket状态变迁图

    在一些防火墙或端口管理工具中经常会看到连接状态为CLOSED CLOSE_WITE LAST_ACK等的进程, 虽然状态就那么很少的几个, 而且看字面意思也能猜个大概, 但没做过Socket编程的朋友 ...

  4. winform中利用反射实现泛型数据访问对象基类(1)

    考虑到软件使用在客户端,同时想简化代码的实现,就写了一个泛型的数据访问对象基类,并不是特别健全,按道理应该参数化的方式实现insert和update,暂未使用参数化,抽时间改进. /// <su ...

  5. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  6. Json 入门例子 多行数组 【1】

    处理以上数据 <script type="text/javascript"> $(function () { $("#fm").click(func ...

  7. #有如下值集合[11,22,33,44,55,66,77,88,99,90...],将所有大于66值保存至字典的一个key中,将小于66的值保存至大二个key的值

    #!/usr/bin/env python #有如下值集合[11,22,33,44,55,66,77,88,99,90...],将所有大于66值保存至字典的一个key中,将小于66的值保存至大二个ke ...

  8. Visual Studio安装项目中将用户选择的安装路径写入注册表的方法[转]

    在你的工程名上右击 -> View ->Registry(视图 -> 注册表) 在你需要写注册表的主键下,例如我注册firefox插件的例子是: (1)右击HKEY_CURRENT_ ...

  9. UVA 442 二十 Matrix Chain Multiplication

    Matrix Chain Multiplication Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %l ...

  10. Cheatsheet: 2014 12.01 ~ 12.31

    .NET Some Thoughts on the new .Net Introducing .NET Core Running ASP.NET on a Raspberry Pi with Mono ...