codeforces 659D . Bicycle Race 几何
题目链接
对相邻的三个点叉积判断一下就好。
#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 几何的更多相关文章
- CodeForces 659D Bicycle Race (判断点是否为危险点)
D - Bicycle Race Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- Codeforces 659D Bicycle Race【计算几何】
题目链接: http://codeforces.com/contest/659/problem/D 题意: 若干条直线围城的湖,给定直线的端点,判断多少个转点会有危险?(危险是指直走的的话会掉进水里) ...
- [ An Ac a Day ^_^ ] CodeForces 659D Bicycle Race 计算几何 叉积
问有多少个点在多边形内 求一遍叉积 小于零计数就好了~ #include<stdio.h> #include<iostream> #include<algorithm&g ...
- codeforces 659D D. Bicycle Race(水题)
题目链接: D. Bicycle Race time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #346 (Div. 2) D Bicycle Race
D. Bicycle Race 题目链接http://codeforces.com/contest/659/problem/D Description Maria participates in a ...
- (求凹包) Bicycle Race (CF 659D) 简单题
http://codeforces.com/contest/659/problem/D Maria participates in a bicycle race. The speedway t ...
- Codeforces Round #346 (Div. 2) D. Bicycle Race 叉积
D. Bicycle Race 题目连接: http://www.codeforces.com/contest/659/problem/D Description Maria participates ...
- D. Bicycle Race_几何
D. Bicycle Race time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 2016NEFU集训第n+3场 D - Bicycle Race
Description Maria participates in a bicycle race. The speedway takes place on the shores of Lake Luc ...
随机推荐
- servlet+ajax+json字符串后台传入,前端解析并把数据循环填入表格实例
写在前面:1.源代码来源于博客http://blog.sina.com.cn/u/2904067371 ,在此基础上对于前端代码稍作更改,把传过来的数据解析并传入表格2.json解析,用eval()3 ...
- BS常用方法备忘
在B/S项目开发过程中总结的一些常用方法,如:常量.验证方法.服务器控件方法.html控件方法等. ///******************* 说明 ************************ ...
- [Linked List]Reverse Linked List,Reverse Linked List II
一.Reverse Linked List (M) Reverse Linked List II (M) Binary Tree Upside Down (E) Palindrome Linked ...
- TCP/IP详解之:IGMP和DNS
第13章 IGMP:Internet组管理协议 IGMP用于支持主机和路由器进行多播: IGMP是IP层的一部分,IGMP报文通过IP数据报进行传输: IGMP报文长度为固定8 Byte: 报文中,I ...
- php将unicode编码转为utf-8方法
介绍 在前端开发中,为了让中文在不同的环境下都能很好的显示,一般是将中文转化为unicode格式,即\u4f60,比如:"你好啊"的 unicode编码为"\u4f60\ ...
- ffmpeg在Win7 VS2010中debug通过,release出错的问题解决方法
我所用的系统环境是Win7 32位操作系统+VS2010编译环境.所以在debug模式下调通之后,在Release模式下调试不通过,最后通过上网查资料和自己对比两个编译选项得出以下结论: 修改“项目- ...
- [Backbone.js]如何处理Model里面嵌入的Collection?
写了近半个月的backbone.js代码,从一开始的todo到现在做仿微信的网页聊天,其中最大的困惑就在于如何处理比较复杂的Model,其内嵌了一个或者多个Collections. 假设我们有一个Pe ...
- [转]Hibernate中property-ref的应用,常用来解决遗留数据库One To Many关系
[转]Hibernate中property-ref的使用,常用来解决遗留数据库One To Many关系 1.如表Class(ClassID,Class_No,ClassName)与Student(S ...
- Oracle EBS-SQL (MRP-2):检查期间主计划录入记录数.sql
SELECT FU.description 创建者, MSD.CREATION_DATE 创建日期, ...
- 移动网络山寨版(OpenBTS)【2】频段的故事
OpenBTS 系统有两个看点.一个是无线收发,尤其是频段的处理,另一个是网络系统,尤其是替代传统的基站(BTS),基站控制器(BSC),移动控制中心(MSC),以及(HLR/VLR)的另类方案. 先 ...