题意:给定 n 个人,每个人两个值s, r,要满足,p(vu) = sqrt((sv − su)^2 + (rv − ru)^2), p(v,u,w) = (p(v,u) + p(v,w) + p(u,w)) / 2

要求找出p(vu) ≥ p(v,u,w) 的对数,其中w是除u,v外,任意的人。
析:化简一下这个表达式,这很明显是两边之和小于等于第三边,好像挺熟悉啊,对,三角形是两边之和大于第三边,现在是小于,不可能,只能是等于,要想等于,
那么只是共线了,并且w是任何人,所以这些点全部都要共线。并且两端的人就是答案,并且只有一对。
代码如下:
  1. #pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include <cstdio>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <set>
  9. #include <queue>
  10. #include <algorithm>
  11. #include <vector>
  12. #include <map>
  13. #include <cctype>
  14. #include <cmath>
  15. #include <stack>
  16. #define frer freopen("in.txt", "r", stdin)
  17. #define frew freopen("out.txt", "w", stdout)
  18. using namespace std;
  19.  
  20. typedef long long LL;
  21. typedef pair<int, int> P;
  22. const int INF = 0x3f3f3f3f;
  23. const double inf = 0x3f3f3f3f3f3f;
  24. const double PI = acos(-1.0);
  25. const double eps = 1e-8;
  26. const int maxn = 2e5 + 5;
  27. const int mod = 1e8;
  28. const char *mark = "+-*";
  29. const int dr[] = {-1, 0, 1, 0};
  30. const int dc[] = {0, 1, 0, -1};
  31. int n, m;
  32. const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  33. const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  34. inline int Min(int a, int b){ return a < b ? a : b; }
  35. inline int Max(int a, int b){ return a > b ? a : b; }
  36. inline LL Min(LL a, LL b){ return a < b ? a : b; }
  37. inline LL Max(LL a, LL b){ return a > b ? a : b; }
  38. inline bool is_in(int r, int c){
  39. return r >= 0 && r < n && c >= 0 && c < m;
  40. }
  41. struct node{
  42. LL x, y;
  43. int id;
  44. node() { }
  45. node(LL xx, LL yy) : x(xx), y(yy){ }
  46. bool operator < (const node &p) const{
  47. return x < p.x || (x == p.x && y < p.y);
  48. }
  49. };
  50. node a[maxn];
  51.  
  52. int main(){
  53. while(scanf("%d", &n) == 1){
  54. LL x, y;
  55. for(int i = 0; i < n; ++i){
  56. scanf("%I64d %I64d", &x, &y);
  57. a[i] = node(x, y);
  58. a[i].id = i+1;
  59. }
  60. bool ok = true;
  61. for(int i = 2; i < n; ++i)
  62. if((a[i-1].x-a[i].x)*(a[i-2].y-a[i].y) != (a[i-1].y-a[i].y)*(a[i-2].x-a[i].x)){ ok = false; break;}
  63.  
  64. if(!ok){ printf("0\n"); continue; }
  65. sort(a, a+n);
  66. printf("1\n%d %d\n", a[0].id, a[n-1].id);
  67. }
  68. return 0;
  69. }

  

URAL 2067 Friends and Berries (推理,数学)的更多相关文章

  1. ural 2067. Friends and Berries

    2067. Friends and Berries Time limit: 2.0 secondMemory limit: 64 MB There is a group of n children. ...

  2. Friends and Berries URAL - 2067 (计算三点共线和计算的时候的注意点)

    题目链接:https://cn.vjudge.net/problem/URAL-2067 具体思路:判断三点共线就可以了,只有一对点能满足,如果一对就没有那就没有满足的. 在计算的时候,要注意,如果是 ...

  3. URAL 1876 Centipede's Morning(数学)

    A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under ...

  4. URAL —— 1255 & HDU 5100——Chessboard ——————【数学规律】

    用 k × 1 的矩形覆盖 n × n 的正方形棋盘 用 k × 1 的小矩形覆盖一个 n × n 的正方形棋盘,往往不能实现完全覆盖(比如,有时候 n × n 甚至根本就不是 k 的整倍数). 解题 ...

  5. 42.Trapping Rain Water---dp,stack,两指针

    题目链接:https://leetcode.com/problems/trapping-rain-water/description/ 题目大意:与84题做比较,在直方图中计算其蓄水能力.例子如下: ...

  6. 数学与猜想 合情推理模式 (G. 波利亚 著)

    第十二章 几个著名模式 (已看) $1. 证实一个结论 $2. 连续证实几个结论 $3. 证实一个未必可信的结论 $4. 类比推理 $5. 加深类比 $6. 被隐没的类比推理 第十三章 更多的模式与最 ...

  7. nyist 303序号互换(数学推理)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=303 思路: 开始看错题了,以为最多只有两个字母. 字母转数字的表达式很容易看出来是:(2 ...

  8. URAL 1820. Ural Steaks(数学啊 )

    题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...

  9. ural 2029 Towers of Hanoi Strike Back (数学找规律)

    ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...

随机推荐

  1. 【JavaScript学习笔记】if使用

    <html> <body> <script language="JavaScript"> var a=4; var b=2; if(a==3) ...

  2. 查看mysql库大小,表大小,索引大小

    查看所有库的大小 mysql> use information_schema; Database changed mysql> selectconcat(round(sum(DATA_LE ...

  3. Cadence Allegro导网表的错误问题解决

    在Allegro导入网表的时候,有时候会出现这样一个错误问题,如下: ------ Oversights/Warnings/Errors ------ #1   ERROR(SPMHNI-235): ...

  4. Servlet、Struts2、SpringMVC执行流程

    Servlet 有以下四个阶段: 1.加载和实例化 Servlet容器负责加载和实例化Servlet. 当Servlet容器启动时,或者在容器检测到需要这个Servlet来响应第一个请求时,创建Ser ...

  5. 【UVa-679】小球下落——二叉树的编号

    在结点1处放一个小球,它会往下落.每个内结点上都会有一个开关,初始全部关闭,当每次有小球落到一个开关上时,状态都会改变.当小球到达一个结点是,如果结点上的开关关闭,则往左走,否则往右走,直到走到叶子的 ...

  6. 【转】安装Django

    原文网址:http://www.crifan.com/record_install_django/ 1.参考Quick install guide,最终找到下载的地址: http://bitnami. ...

  7. tilecache2.11在windows apache2.22安装部署

    tilecache2.11在windows apache2.22安装部署 蔡建良 2013-09-03 一.安装环境 操作系统: Windows7 32位 Apache2.22 Python2.5 m ...

  8. jQuery Mobile中文手册:开发入门

    jQuery Mobile 以“Write Less, Do More”作为目标,为所有的主流移动操作系统平台提供了高度统一的 UI 框架:jQuery 的移动框架可以让你为所有流行的移动平台设计一个 ...

  9. nested push animation can result in corrupted navigation bar

    2013-12-06 10:15:51.668 CodingForFun[4569:70b] nested push animation can result in corrupted navigat ...

  10. C# 一个简单的秒表引发的窗体卡死问题

    一个秒表程序也是我的一个心病,因为一直想写这样的一个东西,但是总往GUI那边想,所以就比较怵,可能是上学的时候学MFC搞出的后遗症吧,不过当我今天想好用Win Form(话说还是第一次写win for ...