https://vjudge.net/contest/389195#problem/C

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.

InputThe 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.OutputFor 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来形成圆,问该圆是逆时针还是顺时针形成。

思路:

  求向量

  内积>0 为顺时针形成

  内积<0 为逆时针形成

(原本还考虑了用参考点的左右相对位置关系来做太麻烦

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
const int maxm=2007;
//const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7; ll x[4] = {0};
ll y[4] = {0};
ll S(int a , int b , int c)
{
ll s = x[a]*y[b] - y[a]*x[b] + x[b]*y[c] - y[b]*x[c] + x[c]*y[a] - y[c]*x[a];
return s;
}
int main()
{
int T = 0;
cin >> T; while(T--)
{
cin >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
bool f = S(1,2,3) > 0;
if(!f)
{
cout << "Clockwise" <<endl;
}
else
{
cout << "Counterclockwise" << endl;
}
}
return 0;
}

  

C - Clockwise or Counterclockwise的更多相关文章

  1. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  2. 会议通js

    js逻辑: /** * Created by wanglijuan on 2016/12/2. */ $(function () { //登陆后请求数据 // $.ajax({ // url:&quo ...

  3. spin.js

    $ajax提交,菊花加载的方式和位置: $.ajax({ type: "get", url: "http://www.xxx.com/test.html", b ...

  4. Gym 100646 F Tanks a Lot RMQ

    Problem F: Tanks a Lot Imagine you have a car with a very large gas tank - large enough to hold what ...

  5. 多种方法实现Loading(加载)动画效果

    当我们ajax提交一个按钮的时候,给那个按钮来个Loading效果会高端很多,体验也会上升个层次. 既能让用户知道正在提交中,也能防止二次提交,好处多多呢.

  6. POJ 3349 Snowflake Snow Snowflakes(简单哈希)

    Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 39324   Accep ...

  7. UVALive 7139 Rotation(矩阵前缀和)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  8. CSS3 笔记四(Transforms/Transition/Animations)

    CSS3 2D Transforms Methods translate() rotate() scale() skewX() skewY() matrix() 1> translate() T ...

  9. Codeforces Round #388 (Div. 2) A,B,C,D

    A. Bachgold Problem time limit per test 1 second memory limit per test 256 megabytes input standard ...

  10. ArrowLayer : A coustom layer animation

    Since my other answer (animating two levels of masks) has some graphics glitches, I decided to try r ...

随机推荐

  1. 基于预生成 QA 对的 RAG 知识库解决方案

    核心价值 QA 预生成技术 采用创新的问答对生成方法,相比传统文本切片技术,能够更精准的构建知识库,显著提升检索与问答效果. 企业级场景验证 已在真实业务场景中落地应用,实现从传统搜索到智能搜索的无缝 ...

  2. http协议中长连接和短连接介绍

      TCP连接 当网络通信时采用TCP协议时,在真正的读写操作之前,客户端与服务器端之间必须建立一个连接,当读写操作完成后,双方不再需要这个连接时可以释放这个连接.连接的建立依靠"三次握手& ...

  3. java springboot项目启动脚本,指定jdk、指定yml配置文件

    start.bat @echo off rem 设置Java路径,根据你的实际情况修改 set JAVA_PATH="./jdk-17.0.6/bin/java.exe" rem ...

  4. 「Log」做题记录 2023.6.15-2023.7.30

    \(2023.6.15-2023.6.18\) \(\color{blueviolet}{CF848C}\) 三维偏序,将询问拆开为每个位置到它的前缀,修改则减去之前的贡献,加上新贡献. 错误: se ...

  5. 二、第一个微信小程序

    使用微信开发者工具创建一个新的空项目,即是一个显示自己账号的小程序. 也可以删除自动生成的冗余代码,手动写一个显示自己账号的简单小程序. 下面即是基于JavaScript模板的手工写的一个简单小程序. ...

  6. 一个基于 .NET 开源、模块化 AI 图像生成 Web 用户界面

    前言 今天大姚给大家分享一个基于 .NET 开源.模块化 AI 图像生成 Web 用户界面:SwarmUI. 项目介绍 SwarmUI (原 StableSwarmUI)是一个基于 .NET 开源(M ...

  7. SpringBoot集成TOTP双因素认证(2FA)实战

    一.双因素认证的概念 双因素认证(2FA,Two Factor Authentication)又称双因子认证.两步验证,指的是是一种安全认证过程,需要用户提供两种不同类型的认证因子来表明自己的身份,包 ...

  8. AI生成的一篇官网代码,有兴趣可以参考一下

    <!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8&qu ...

  9. 实战干货|Spark 在袋鼠云数栈的深度探索与实践

    Spark 是一个快速.通用.可扩展的大数据计算引擎,具有高性能.易用.容错.可以与 Hadoop 生态无缝集成.社区活跃度高等优点.在实际使用中,具有广泛的应用场景: · 数据清洗和预处理:在大数据 ...

  10. HyperWorks中的Size and bias 子面板

    此面板是 automesh 经常使用的子面板,通过此面板,用户可用设置单元尺寸.单元类型以及以及映射类型等多种控制选项,然后通过预览按钮查看待生成网格模型的状态.   图 3-6 size and b ...