题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=2701

题意

有一个萤火虫会闪现 一个人 也会闪现 给出 这个人的起始位置 和他能够闪现的距离 然后依次给出萤火虫的坐标 这个人 每次都往萤火虫的坐标闪现 如果 这个人能够到达的距离方圆1个单位长度以内 萤火虫在里面 那么这个人就能够抓住萤火虫 就输出坐标 如果最后都没有抓住 那么 就是抓不住了

思路

只要模拟一下就好了

求这个人每次移动的坐标 学长点了我一下,,竟然是用相似三角形。。初中的东西啊。。

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a, b) memset(a, (b), sizeof(a))
#define pb push_back using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss; const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-8; const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const int MOD = 1e9; double getdis(double x1, double y1, double x2, double y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
} int main()
{
double n, x, y;
int t = 1;
while (scanf("%lf%lf%lf", &n, &x, &y) && (n || x || y))
{
double a, b;
int flag = 1;
while (scanf("%lf%lf", &a, &b) && (a != -1 || b != -1))
{
if (flag)
{
double dis = getdis(x, y, a, b);
if (dis <= n + 1.0)
{
printf("Firefly %d caught at (%.0lf,%.0lf)\n", t++, a, b);
flag = 0;
}
x += (a - x) * n / dis;
y += (b - y) * n / dis;
} }
if (flag)
printf("Firefly %d not caught\n", t++);
}
}

最新文章

  1. 在CentOS 6.4 x86_32中使用Rhythmbox听MP3
  2. js数组转置
  3. 【英语】Bingo口语笔记(38) - See系列
  4. Android 开发之自定义Dialog及UI的实现
  5. codeforces #286 Div.2 C DP总是以意外的方式打败我
  6. Implement a Linked List
  7. url地址栏拼接参数写法
  8. 用C#语言编写:集合管理器
  9. js对象取值的两种方式
  10. 解决Mac应用程序软件不出现在Launchpad里面的方法
  11. echarts使用踩坑实录之气泡图
  12. 使用 Zabbix 监控 Jenkins
  13. (一)flask-sqlalchemy的安装和配置
  14. python框架相关问题
  15. postgresql change table
  16. 使用nginx+tomcat将所有请求都转发到一个页面
  17. 高通 打开 wifi 驱动 log
  18. Java网络编程之查找Internet地址
  19. PCI &amp; PCIE Configuration Register Space
  20. Redis-与python交互

热门文章

  1. JDBC技术总结(二)
  2. jdk1.6 升级到 jdk1.7
  3. Memcache遍历查询所有键值的方法
  4. mysql更改表结构:添加、删除、修改字段、调整字段顺序
  5. C语言小板凳(1)
  6. 【数据挖掘】分类之decision tree(转载)
  7. gen_server2 与gen_server的对比
  8. Angular1.0 在Directive中调用Controller的方法
  9. Google Gson实现JSON字符串和对象之间相互转换
  10. React Native安装步骤