hdu 3718 Different Division
Different Division
points referred above) is on the left side of the line, or lying on the line. or on the right side of the line. For example,

There are four points in the graph: A, B, C, D. we connect C and D. Now C and D form a new line “CD”. Obviously, C and D are lying on the line “CD”. A is on the right side of CD, and B is on the left side of CD. What’s more, A is on the left side of line DC,
and B is on the right side of line DC. So line “CD” and “DC” are different in this problem;
N lines followed, each line contains two real numbers X, Y, indicating the coordinates of points. Then one line follows, contains two integers P1 and P2 indicate the P1th point and the P2th point in this case.
1<= T <= 100
2 <= N <= 1000
1<= P1, P2 <= N, P1 != P2
-1000 < X, Y < 1000;
is on the right side of line P1P2.
4
1 1
1 2
3 3
2 1
1 3
Left
On
Right
<span style="font-size:18px;">#include <cstdio>
#include <iostream>
using namespace std;
#define N 1005
double a[N],b[N];
int main()
{
int t;
double x1,x2,y1,y2,sum;
scanf("%d",&t);
while(t--)
{
int n,i;
scanf("%d",&n);
for(i = 1; i <= n; i++)
scanf("%lf%lf",&a[i],&b[i]);
int p1,p2;
scanf("%d%d",&p1,&p2);
x1 = a[p2] - a[p1];
y1 = b[p2] - b[p1];
for(i=1; i<=n; i++)
{
x2 = a[i] - a[p1];
y2 = b[i] - b[p1];
sum = x1*y2 - x2*y1;
if(sum < 0)
printf("Right\n");
else if(sum > 0)
printf("Left\n");
else printf("On\n");
}
}
return 0;
}</span>
hdu 3718 Different Division的更多相关文章
- HDU 3718 Similarity(KM最大匹配)
HDU 3718 Similarity 题目链接 题意:给定一个标准答案字符串,然后以下每一行给一个串.要求把字符一种相应一种,要求匹配尽量多 思路:显然的KM最大匹配问题,位置相应的字符连边权值+1 ...
- 【HDU】3480 Division
http://acm.hdu.edu.cn/showproblem.php?pid=3480 题意:一个n个元素的集合S要求分成m个子集且子集并为S,要求$\sum_{S_i} (MAX-MIN)^2 ...
- 【HDU 6036】Division Game (NTT+数学)
多校1 1004 HDU-6036 Division Game 题意 有k堆石头(0~k-1),每堆n个.\(n=\prod_{i=0}^{m}p_i^{e_i}\).\(0\le m,k \le 1 ...
- hdu 3718
一个二分图最大匹配的题: 匈牙利算法不熟: 建了个模,用最小费用最大流解决了 #include <iostream> #include <cstring> #define IN ...
- HDU 5845 Best Division
$dp$,字典树. $dp$递推式很容易知道.dp[i]=max{dp[j]+1} a[j]^..^a[i]<=X,并且$[j,i]$长度不能超过$L$. 但是暴力来复杂度极高,所以需要用字典树 ...
- KM HDU 3718
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- hdu 3480 Division(斜率优化DP)
题目链接:hdu 3480 Division 题意: 给你一个有n个数的集合S,现在让你选出m个子集合,使这m个子集合并起来为S,并且每个集合的(max-min)2 之和要最小. 题解: 运用贪心的思 ...
- HDU 6036 - Division Game | 2017 Multi-University Training Contest 1
/* HDU 6036 - Division Game [ 组合数学,NTT ] | 2017 Multi-University Training Contest 1 题意: k堆石子围成一个圈,数量 ...
- HDU 6036 Division Game
HDU 6036 Division Game 考虑每堆石头最多操作 $ \sum e $ 次,考虑设 $ f(x) $ 表示某一堆石头(最开始都是一样的)操作 $ x $ 次后变成了 $ 1 $ 的方 ...
随机推荐
- Angular 学习笔记——factory
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- 系统封装 如何修改别人的PE为己所用
我们以修改"我心如水 WIN7PE_16.99.1 维护版.ISO"为例,整个ISO的核心文件就是这个BOOT.WIM,我们先把他提取出来. 然后用在本教程第一章学到的东西,用AI ...
- 已加载“C:\Windows\SysWOW64\ntdll.dll”。无法查找或打开 PDB 文件。
“Win32Project3.exe”(Win32): 已加载“D:\software\VS2013\VS2013 文档\Win32Project3\Debug\Win32Project3.exe”. ...
- C++_友元函数(转)
1.为什么要引入友元函数:在实现类之间数据共享时,减少系统开销,提高效率 具体来说:为了使其他类的成员函数直接访问该类的私有变量 即:允许外面的类或函数去访问类的私有变量和保护变量,从而使两个类共享同 ...
- apue学习笔记(第三章 文件I/O)
本章开始讨论UNIX系统,先说明可用的文件I/O函数---打开文件.读写文件等 UNIX系统中的大多数文件I/O只需用到5个函数:open.read.write.lseek以及close open函数 ...
- 初窥Servlet
1. Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术.sun公司在其API中提供了一个servlet接口,用户若想要发一个动态web资源,只需要完成以下两步即可: ...
- UIView的endEditing:方法
当视图收到endEditing:消息时,如果视图(或者其下的人和子视图)是当前的第一响应对象,就会取消自己的第一响应对象状态, 而且虚拟键盘也会消失(传入的参数代表是否需要强制取消第一响应对象状态.有 ...
- windows 网站迁移到linux
从windows迁移网站到linux 发现乱码 出现这种情况的原因为两种操作系统的中文压缩方式不同,在windows环境中中文一般为gbk,而在linux环境中为utf8,这就导致了在windows下 ...
- Java 入门课程视频实战-0基础 上线了,猜拳游戏,ATM实战,欢迎围观
Java 入门课程视频实战-0基础 已经上传完了.欢迎小伙伴们过来围观 直接进入: http://edu.csdn.net/course/detail/196 课程文件夹例如以下: 1 初识Java ...
- Atitit.dart语言的特性 编译时js语言大总结
Atitit.dart语言的特性 编译时js语言大总结 1. 原型环境1 1.1. Dart可以编译js3 2. 第二个期待的理由是Dart的语言特性,没有什么特别特性好像,类似java c#一小时 ...