题目链接


题目大意:就是给你两个左右手的模型,下面给出这两只手通过平移变换之后坐标问你这只手是左手还是右手?[题目保证坐标是按照顺时针或者逆时针给出的]


解题思路:首先我们先观察一下这只右手:假如数据是按照逆时针给出的那么(1,6),(1,0),(10,0)这三个点构成的两条边就会依次出现因为这两条边的长度是6和9是独一无二的所以我们可以先特判一下数据给出的方向然后for循环一遍寻找这两条边
1.如果是逆时针并且找的到这两条边那么就是右手否则就是左手
2.如果是时针并且找的到这两条边那么就是左手否这就是右手


判断顺逆时针的模板:

#include<iostream>
using namespace std;
int x[35], y[35];
int main(){int N;cin >> N;for (int i = 0; i < N; i++)cin >> x[i] >> y[i];int d = 0;for (int i = 0; i < N - 1; i++)d += -0.5 * (y[i + 1] + y[i]) * (x[i + 1] - x[i]);if(d > 0)cout << "counterclockwise"<< endl;//逆elsecout << "clockwise" << endl;//顺}

AC代码:eps>1e-5:否者会wa


#include <iostream>
#include <cstdio>
#include <stack>
#include <sstream>
#include <vector>
#include <map>
#include <cstring>
#include <deque>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
#define mid ((l + r) >> 1)
#define Lson rt << 1, l , mid
#define Rson rt << 1|1, mid + 1, r
#define ms(a,al) memset(a,al,sizeof(a))
#define log2(a) log(a)/log(2)
#define _for(i,a,b) for( int i = (a); i < (b); ++i)
#define _rep(i,a,b) for( int i = (a); i <= (b); ++i)
#define for_(i,a,b) for( int i = (a); i >= (b); -- i)
#define rep_(i,a,b) for( int i = (a); i > (b); -- i)
#define lowbit(x) ((-x) & x)
#define IOS std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 0x3f3f3f3f
#define hash Hash
#define next Next
#define count Count
#define pb push_back
#define f first
#define s second
using namespace std;
const int N = 2e6+10, mod = 1e9 + 7;
const long double eps = 1e-5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
template<typename T> void read(T &x)
{x = 0;char ch = getchar();ll f = 1;while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args)
{read(first);read(args...);
}
struct Point//点或向量
{double x, y;Point() {}Point( double x, double y) :x(x), y(y) {}
};
typedef Point Vector;
int dcmp( double x)//精度三态函数(>0,<0,=0)
{if (fabs(x) < eps)return 0;else if (x > 0)return 1;return -1;
}
Vector operator + (Vector a, Vector b)//向量加法
{return Vector(a.x + b.x, a.y + b.y);
}
Vector operator - (Vector a, Vector b)//向量减法
{return Vector(a.x - b.x, a.y - b.y);
}
Vector operator * (Vector a, double p)//向量数乘
{return Vector(a.x*p, a.y*p);
}
Vector operator / (Vector a, double p)//向量数除
{return Vector(a.x / p, a.y / p);
}double Distance(Point a, Point b)//两点间距离
{return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
bool operator == (const Point &a, const Point &b)//向量相等
{return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
}long double Cross(Vector a, Vector b)//外积
{return a.x*b.x + a.y*b.y;
}bool cmp1(Point a,Point b)
{if(atan2(a.y,a.x)!=atan2(b.y,b.x))return atan2(a.y,a.x)<atan2(b.y,b.x);else return a.x<b.x;
}Point a[22];
int main()
{int T;read(T);while(T --){for(int i = 0; i < 20; ++ i)cin >> a[i].x >> a[i].y;double s = 0;bool flag = 1;for(int i = 0; i < 19; ++ i)s += -0.5 * (a[i + 1].y + a[i].y) * (a[i + 1].x - a[i].x);s += -0.5 * (a[0].y + a[19].y) * (a[0].x - a[19].x);if(s > 0) flag = 1;else flag = 0;int tmp = -1; if(!flag){ for(int i = 0; i < 20; ++ i)if(dcmp(Distance(a[(i-1+20)%20],a[i]) - 6.0) == 0 && dcmp(Distance(a[(i+1)%20],a[i]) - 9.0) == 0){tmp = i;puts("left");break;}if(tmp == -1) puts("right");}else {for(int i = 0; i < 20; ++ i)if(dcmp(Distance(a[(i-1+20)%20],a[i]) - 6.0) == 0 && dcmp(Distance(a[(i+1)%20],a[i]) - 9.0) == 0){tmp = i;puts("right");break;}if(tmp == -1) puts("left");}}return 0;
}

2020牛客多校第三场[C Operation Love+基础计算几何 判断多边形顺逆时针]相关推荐

  1. exgcd ---- 2020牛客多校第三场:[Fraction Construction Problem:exgcd+思维题]

    题目链接 题目大意:就是给你两个数a,ba,ba,b叫你求满足下面三个条件的c,d,e,fc,d,e,fc,d,e,f 1.cd−ef=ab1.{c\over d}-{e\over f}={a\ove ...

  2. 24dian(牛客多校第三场)

    24dian(牛客多校第三场) 题意: 给你n张牌,每张牌的大小为1 ~ 13,问这些牌与加减乘除任意组合(可以使用括号),且但所有的有效解在计算过程中都涉及到分数,即非整数,能否组成答案m,如果可以 ...

  3. 牛客多校第三场 B【Classical String Problem】

    牛客多校第三场 B[Classical String Problem] 链接:https://ac.nowcoder.com/acm/contest/5668/B 来源:牛客网 题目描述 Given ...

  4. 牛客多校第三场A【Clam and fish】贪心

    A[Clam and fish]贪心 链接:https://ac.nowcoder.com/acm/contest/5668/A 来源:牛客网 题目: There is a fishing game ...

  5. 2019牛客多校 第七场 B Irreducible Polynomial 多项式因式分解判断

    链接:https://ac.nowcoder.com/acm/contest/887/B 来源:牛客网 Irreducible Polynomial 时间限制:C/C++ 1秒,其他语言2秒 空间限制 ...

  6. Splay ---- 2018牛客多校第三场 区间翻转搞区间位移 或者 rope可持久化块状链表

    题目链接 题目大意: 就是每次把牌堆中若干个连续的牌放到堆顶,问你最后牌的序列. 解题思路: Splay 区间翻转的模板题: 对于一个区间[1,2,3,4,5,6,7,8][1,2,3,4,5,6,7 ...

  7. 2020牛客多校第1场H-Minimum-cost Flow

    解题思路: 首先我们要从费用流mcmf的算法入手:因为它每次增广是再费用增广路上跑的,根据贪心的思想费用小的路基本上能运多少就尽量运多少,所以我们可以假设初始的边容量是1,只跑一遍mcmf.记录一下每 ...

  8. 数论分块 ---- 2020牛客多校第7场H-Dividing[思维+数论分块]

    题目大意: 解题思路:很明显满足条件的点是n%k==0∣∣n%k==1n\%k==0||n\%k==1n%k==0∣∣n%k==1 1.因为nnn是从111开始的如果一直乘以k[n=n∗k]k[n=n ...

  9. 2020牛客多校第7场C-A National Pandemic[树链剖分+思维]

    题目大意 1.首先我们看一下操作1:实际上可以说成在所有位置上加上w−dist(x,y)w-dist(x,y)w−dist(x,y),因为dist(x,x)=0dist(x,x)=0dist(x,x) ...

最新文章

  1. 谈谈Python那些不为人知的冷知识(一)
  2. java获取2017年第39周_java中怎么样取出39周的每周开始时间和每周结束时间?
  3. 如何启用和关闭数据库的Oracle归档模式
  4. 【Python CheckiO 题解】Army Battles
  5. 吴裕雄 实战PYTHON编程(7)
  6. PHP curl get post通用类
  7. 我为什么要帮你查 Bug?
  8. 关于小米手机网站抢购的一点技术分析
  9. 我手机计算机屏幕是黑色的,教你处理手机或者电脑黑屏的简单方法
  10. thinkpad卡在logo界面_win7系统开机卡在Thinkpad LOGO画面无法进入桌面的解决方法
  11. elementUI 输入框添加小图标
  12. 深入支付宝支付扫描支付-跳转支付宝二维码页面支付与自定义生成二维码支付-2跳转固定的支付宝页面进行扫码支付
  13. 实现点击按钮关闭微信小程序功能(附源码)
  14. YUI可真是个不错的东东
  15. Linux常用操作命令(一)
  16. 买天猫网店转让成为电商创业新趋势
  17. UE4元数据关键字的应用与含义(一)
  18. 如何运用亚马逊、Facebook、Etsy选品?选品平台和方法分享
  19. 解决Pytorch转onnx错误:Only tuples, lists and Variables are supported as JIT inputs/outputs!
  20. idea工具整合前端vue,nodeJs步骤

热门文章

  1. 如何入门论文阅读综述小解答
  2. 网络应用 axIos的基本使用
  3. 防火墙产品原理与应用:NAT支持的特殊协议
  4. PyTorch Cookbook(常用代码段集锦)
  5. 如何评判一个深度学习框架?
  6. 链表问题3——删除链表的中间节点(初阶)
  7. SpringBoot 学习 | raibaby halo 之安装部署 - Ali0th
  8. 智能家居隐私问题再遭热议:涉案设备中的数据究竟受不受保护?
  9. Dialog 去白色边框及透明
  10. JAVA逆向反混淆-追查Burpsuite的破解原理(转)