题意:给定 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是任何人,所以这些点全部都要共线。并且两端的人就是答案,并且只有一对。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define frer freopen("in.txt", "r", stdin)
#define frew freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 2e5 + 5;
const int mod = 1e8;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
struct node{
LL x, y;
int id;
node() { }
node(LL xx, LL yy) : x(xx), y(yy){ }
bool operator < (const node &p) const{
return x < p.x || (x == p.x && y < p.y);
}
};
node a[maxn]; int main(){
while(scanf("%d", &n) == 1){
LL x, y;
for(int i = 0; i < n; ++i){
scanf("%I64d %I64d", &x, &y);
a[i] = node(x, y);
a[i].id = i+1;
}
bool ok = true;
for(int i = 2; i < n; ++i)
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;} if(!ok){ printf("0\n"); continue; }
sort(a, a+n);
printf("1\n%d %d\n", a[0].id, a[n-1].id);
}
return 0;
}

  

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. 4.0之后的hibernate获取sessionFactory

    static{ Configuration config=new Configuration().configure(); ServiceRegistry resgistry = new Servic ...

  2. Java 动态写轮眼 SharinganJPanel (整理)

      /** * Java 动态写轮眼 SharingganJPanel (整理) * * 2016-1-2 深圳 南山平山村 曾剑锋 * 设计声明: * 1.虽然岸本是日本人,而我个人作为其模仿者,依 ...

  3. 【C#学习笔记】保存文件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. 基于catalog 创建RMAN存储脚本

    --============================== -- 基于catalog 创建RMAN存储脚本 --============================== 简言之,将rman的 ...

  5. python基础之使用os.system来执行系统命令

    今天我们来尝试使用python 的os.system来执行系统命令 可以使用如下方法: import osprint os.system('ping www.baidu.com') 输出的结果是:64 ...

  6. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.5.安装Grid,创建ASM磁盘组空间不足

    因之前分区时,分区的Last cylinder的值选了“1”,导致创建磁盘组空间不足.解决办法是先删除分区,重新创建分区并删除ASM磁盘,然后重建ASM磁盘 1. 先删除分区,重新创建分区: 1)查询 ...

  7. php 正则中的"i,m,s,x,e"分别表示什么

    i如果设定此修正符,模式中的字符将同时匹配大小写字母.m当设定了此修正符,“行起始”和“行结束”除了匹配整个字符串开头和结束外,还分别匹配其中的换行符的之后和之前.s如果设定了此修正符,模式中的圆点元 ...

  8. Informatica9.6.1在Linux Red Hat 5.8上安装遇到的有关问题整理_3

    3.Repository Service启动后的页面编码问题 1)错误信息: 2)原因分析及解决步骤 原因分析: informatica产品安装背后AdminConsole的Code page默认为U ...

  9. ASP.NET Cookie对象到底是毛啊?(简单小例子)

    记得刚接触asp.net的时候,就被几个概念搞的头痛不已,比如Request,Response,Session和Cookie.然后还各种在搜索引擎搜,各种问同事的,但是结果就是自己还是很懵的节奏. 那 ...

  10. Red and Black ---路线问题

    There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A ...