题目链接

对相邻的三个点叉积判断一下就好。

#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, n, a) for(int i = a; i<n; i++)
#define fi first
#define se second
typedef complex <double> cmx;
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9+7;
const int inf = 1061109567;
const int dir[][2] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1} };
const int maxn = 1005;
int cross(int x1, int y1, int x2, int y2, int x3, int y3) {
return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1);
}
int x[maxn], y[maxn];
main()
{
int n;
cin>>n;
n++;
for(int i = 0; i < n; i++){
cin>>x[i]>>y[i];
}
n--;
int ans = 0;
for(int i = 0; i < n; i++){
ans += (cross(x[i], y[i], x[(i+1)%n], y[(i+1)%n], x[(i+2)%n], y[(i+2)%n])>0);
}
cout<<ans<<endl;
}

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【计算几何】

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

  3. [ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积

    问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm&g ...

  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. D. Bicycle Race_几何

    D. Bicycle Race time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

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

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

随机推荐

  1. for练习--凑法

    static void Main14购物卡(string[] args) { //小明单位发了50元的购物卡,他到超市买洗化用品,一是牙刷(5元),二是香皂(2元),三是牙膏(10元)怎么可以正好把五 ...

  2. 在ASP.NET MVC自定义错误页面

    异常处理跳转页面 第一步,在项目的Web.config文件中找到节点<system.web> 在此节点下添加配置(Error为定义的控制器也可以多添加些error标签用于区分不同的错误) ...

  3. Bootstrap插件——(Tab)标签页

    项目中用到了Bootstrap的(Tab)标签页插件,记录如下: 代码如下: <div class="tabbable"> <ul class="nav ...

  4. [stack]Evaluate Reverse Polish Notation

    Total Accepted: 55722 Total Submissions: 249668 Difficulty: Medium Evaluate the value of an arithmet ...

  5. python基础:列表生成式和生成器

    列表生成式(List Comprehension) 列表生成式即List Comprehensions,是Python内置的非常简单却强大的可以用来创建list的生成式. 举个例子,要生成 list ...

  6. php中json_encode中文编码问题

    1 <?php 2 class myClass { 3 public$item1=1; 4 public$item2='中文'; 5 6 function to_json() { 7 //url ...

  7. wamp出现You don’t have permission to access/on this server提示(转)

    转自http://blog.csdn.net/hong0220/article/details/40262729 ,转载方便以后查看. 今天搭建wamp集成环境,本来已经搭建好了,但是在访问local ...

  8. 《UNIX网络编程》TCP客户端服务器:并发、消息回显

    经过小小改动,把前面基础的例子做出一点修改. 并发服务器,服务器每accept一个请求就fork()一个新的子进程. 编译运行方法同前一篇. /*client_tcp.c*/ #include < ...

  9. vimTAB宽度等设置

    10 set shiftwidth=4 11 set softtabstop=4 12 set textwidth=200 13 set nu 14 set autoindent 15 set noe ...

  10. 行变列 拼接字符串 MSSQL 一个超级搞的问题

    由数据 ThreeLevelSortID KeyWordID KeyWordName key1 key2 key3 key4 得到数据大 ThreeLevelSortID KeyWordName ke ...