hdu2020 多校7 Clockwise or Counterclockwise

Problem Description
It is preferrable to read the pdf statment.

After some basic geometric lessons, Cuber QQ has learned that one can draw one and only one circle across three given distinct points, on a 2D plane. Specialized in art, Cuber QQ has shown remarkable skills to draw circle in one stroke, especially when the stroke is done clockwise. He wonder whether he will be able to do that if 3 points has been given.

In particular, he is given three distinct points A(x1,y1), B(x2,y2), C(x3,y3) which lie on a circle centered at O(0,0). Imagine starting from A, he draws the circle across B and finally gets C. Determine whether he is drawing clockwise or counterclockwise.

Input
The first line contains an integer T (1≤T≤1 000), denoting the number of test cases.

In the next T lines, each line contains six space-separated integers x1, y1, x2, y2, x3, y3 (−109≤x1,y1,x2,y2,x3,y3≤109) denoting the coordinate of A, B and C.

It is guaranteed that A, B, C are pairwise distinct and |AO|=|BO|=|CO|>0.

Output
For each test case, output one line containing ‘‘Clockwise’’ or ‘‘Counterclockwise’’.

Sample Input
3
1 2 2 1 -1 -2
4 3 -4 3 3 4
4 -3 4 3 3 4

Sample Output
Clockwise
Clockwise
Counterclockwise

题意:
平面中三点a,b,c;求a->b->c是顺时针还是逆时针。
如果是平面上的三点bai(x1,y1),(x2,y2),(x3,y3),那只要看行列式
x1 y1 1
x2 y2 1
x3 y3 1
的符号就行了(百度一搜就有)
大于0是逆时针,反之是顺时针。
代码:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=210,M=1e4+10;
const int INF=0x3f3f3f3f;
ll x1,y1,x2,y2,x3,y3;
int main()
{
   int t;
   scanf("%d",&t);
   while(t--)
   {
       scanf("%lld%lld%lld%lld%lld%lld",&x1,&y1,&x2,&y2,&x3,&y3);
       ll ans=(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
       if(ans>0)
       printf("Counterclockwise\n");
       else printf("Clockwise\n");
   }
   return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值