问有多少个点在多边形内

求一遍叉积 小于零计数就好了~

 #include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
struct point{
int x,y;
}pnt[];
int solve(point a,point b,point c){
return (b.x-a.x)*(c.y-b.y)-(c.x-b.x)*(b.y-a.y);
}
int main(){
int n;
scanf("%d",&n);
n++;
for(int i=;i<n;i++)
scanf("%d%d",&pnt[i].x,&pnt[i].y);
int ans=;
for(int i=;i<n;i++)
if(solve(pnt[i-],pnt[i-],pnt[i])>) ans++;
printf("%d\n",ans);
return ;
}
/* 6
0 0
0 1
1 1
1 2
2 2
2 0
0 0 16
1 1
1 5
3 5
3 7
2 7
2 9
6 9
6 7
5 7
5 3
4 3
4 4
3 4
3 2
5 2
5 1
1 1 */

[ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积的更多相关文章

  1. CodeForces 659D Bicycle Race (判断点是否为危险点)

    D - Bicycle Race Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  2. codeforces 659D . Bicycle Race 几何

    题目链接 对相邻的三个点叉积判断一下就好. #include <iostream> #include <vector> #include <cstdio> #inc ...

  3. Codeforces 659D Bicycle Race【计算几何】

    题目链接: http://codeforces.com/contest/659/problem/D 题意: 若干条直线围城的湖,给定直线的端点,判断多少个转点会有危险?(危险是指直走的的话会掉进水里) ...

  4. codeforces 659D D. Bicycle Race(水题)

    题目链接: D. Bicycle Race time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Codeforces Round #346 (Div. 2) D Bicycle Race

    D. Bicycle Race 题目链接http://codeforces.com/contest/659/problem/D Description Maria participates in a ...

  6. (求凹包) Bicycle Race (CF 659D) 简单题

    http://codeforces.com/contest/659/problem/D     Maria participates in a bicycle race. The speedway t ...

  7. Codeforces Round #346 (Div. 2) D. Bicycle Race 叉积

    D. Bicycle Race 题目连接: http://www.codeforces.com/contest/659/problem/D Description Maria participates ...

  8. 2016NEFU集训第n+3场 D - Bicycle Race

    Description Maria participates in a bicycle race. The speedway takes place on the shores of Lake Luc ...

  9. Codeforces Gym 100733A Shitália 计算几何

    ShitáliaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.acti ...

随机推荐

  1. MyBatis 学习-动态 SQL 篇

    MyBatis 为我们提供了如下几个动态 SQL 元素: if choose foreach where/set trim 一.IF 元素 <select id="selectProj ...

  2. cos距离与欧式距离

    1. 欧氏距离(EuclideanDistance) 欧氏距离是最易于理解的一种距离计算方法,源自欧氏空间中两点间的距离公式. (1)二维平面上两点a(x1,y1)与b(x2,y2)间的欧氏距离: ( ...

  3. linux 发送带附件的邮件

    一.mutt命令 1.安装 yum -y install mutt 2.使用 echo "mail content"|mutt -s "mail title"  ...

  4. 递归——CPS(二)

    给出一个计算树深度的函数: function treeDepth(curtree) { if(curtree == null) return 0; else { var leftDepth = tre ...

  5. 关于string转整数

    又是leetcode的easy级别题,很基本的题目,却漏考虑很多情况,动手前一定要考虑清楚呀!!! 就当做锻炼写作能力吧,先上题目! 将文本转换成整数,注意一下几点: 1.文本里面第一个不为空白的字符 ...

  6. centos php nginx 添加到service

    1. nginx A. # vi /etc/init.d/nginx B. #!/bin/sh # Comments to support chkconfig on RedHat Linux # ch ...

  7. java学习开题

  8. HDU 1079 Calendar Game 博弈

    题目大意:从1900年1月1日 - 2001年11月4日间选择一天为起点,两个人依次进行两种操作中的任意一种,当某人操作后为2001年11月4日时,该人获胜.问先手是否获胜 操作1:向后移一天 操作2 ...

  9. Linux下区分物理CPU、逻辑CPU和CPU核数

    ㈠ 概念           ① 物理CPU                             实际Server中插槽上的CPU个数              物理cpu数量,可以数不重复的 p ...

  10. mac 配置快捷键快速锁屏

    mac下锁屏方式有很多: 快捷键control+shift+power 在其他中打开钥匙串访问,讲屏幕锁定按钮显示在menu bar中 这两种方法存在弊端: 按三个键去锁定屏幕太费劲,况且让使用外接键 ...