zoukankan      html  css  js  c++  java
  • UVALive 4168

    呵呵呵......................................

    感觉受到了一千万点的伤害.........就这几句话......第三条......开始以为是在一个格子里......后来根据样例觉得还是在哪个点上.....再后来debug一个点.....

    尼玛....原来的距离是比1小....累觉不爱....人艰不拆.....

    好烦...比赛的时候为什么没有看出来是这个呢...

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<map>
     4 #include<vector>
     5 #include<iostream>
     6 #include<math.h>
     7 using namespace std;
     8 
     9 int main()
    10 {
    11     double dis, st, ed;
    12     int cnt = 0;
    13     while(~scanf("%lf%lf%lf", &dis, &st, &ed))
    14     {
    15         if (dis == 0) break;
    16         int x, y;
    17         bool flag = true;
    18         int fx, fy;
    19         while(scanf("%d%d", &x, &y))
    20         {
    21             if (x == -1 && y == -1)
    22                 break;
    23             if (flag == false) continue;
    24             fx = x;
    25             fy = y;
    26             double tx, ty;
    27             if (x != st)
    28             {
    29                 double k = (y-ed) * 1.0 / (x-st);
    30                 if (k < 0) k = -k;
    31                 double ang = atan(k);
    32                 tx = dis*cos(ang);
    33                 ty = dis*sin(ang);
    34             }
    35             else if (x == st)
    36             {
    37                 tx = 0;
    38                 ty = dis;
    39             }
    40             double yy = (y-ed)*(y-ed);
    41             double xx = (x-st)*(x-st);
    42             double dd = sqrt((yy+xx));
    43 
    44             if (dd <= dis + 1)
    45             {
    46                 flag = false;
    47                 continue;
    48             }
    49             if (x >= st) st += tx;
    50             else st -= tx;
    51             if (y >= ed) ed += ty;
    52             else ed -= ty;
    53             if (st < 0) st = 0;
    54             if (ed < 0) ed = 0;
    55         }
    56         if (flag) printf("Firefly %d not caught
    ", ++cnt);
    57         else  printf("Firefly %d caught at (%d,%d)
    ", ++cnt, fx, fy);
    58     }
    59     return 0;
    60 }
    LOoK
  • 相关阅读:
    5.深入TiDB:Insert 语句
    4.深入TiDB:执行计划执行过程详解
    3.深入TiDB:执行优化讲解
    2.深入TiDB:入口代码分析及调试 TiDB
    1.深入TiDB:初见TiDB
    开发必备之单元测试
    如何用好MySQL索引
    SpringBoot运行源码剖析(一)
    深入理解Java虚拟机读后感
    Java并发编程艺术读后感
  • 原文地址:https://www.cnblogs.com/icode-girl/p/4705553.html
Copyright © 2011-2022 走看看