hdu2020 多校7 Clockwise or Counterclockwise

郑晗日
2023-12-01

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;
}
 类似资料: