C - Clockwise or Counterclockwise
https://vjudge.net/contest/389195#problem/C
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的更多相关文章
- 2016ACM青岛区域赛题解
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- 会议通js
js逻辑: /** * Created by wanglijuan on 2016/12/2. */ $(function () { //登陆后请求数据 // $.ajax({ // url:&quo ...
- spin.js
$ajax提交,菊花加载的方式和位置: $.ajax({ type: "get", url: "http://www.xxx.com/test.html", b ...
- 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 ...
- 多种方法实现Loading(加载)动画效果
当我们ajax提交一个按钮的时候,给那个按钮来个Loading效果会高端很多,体验也会上升个层次. 既能让用户知道正在提交中,也能防止二次提交,好处多多呢.
- POJ 3349 Snowflake Snow Snowflakes(简单哈希)
Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 39324 Accep ...
- UVALive 7139 Rotation(矩阵前缀和)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...
- CSS3 笔记四(Transforms/Transition/Animations)
CSS3 2D Transforms Methods translate() rotate() scale() skewX() skewY() matrix() 1> translate() T ...
- 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 ...
- ArrowLayer : A coustom layer animation
Since my other answer (animating two levels of masks) has some graphics glitches, I decided to try r ...
随机推荐
- MCP Server On FC 之旅第四站: 长连接闲置计费最高降低87%成本的技术内幕
函数计算( FC )是阿里云事件驱动的全托管计算服务, 使用函数计算,您无需采购与管理服务器等基础设施,只需编写并上传代码或镜像.函数计算为您准备好计算资源,弹性地.可靠地运行任务,并提供日志查询.性 ...
- 【MySQL】字符串截取函数substring_index
业务场景描述:如何根据分隔符切割字符串?使用函数SUBSTRING_INDEX()根据指定分隔符切割,分隔符可以是字符串等. 语法:substring_index(str,delim,count) 说 ...
- Windows安装MySQL常见错误
错误1:提示缺少Visual Studio 2019 x64 Redistributable 现象: 在windows系统上使用Mysql8以上的msi进行安装时,可能提示缺少Visual Studi ...
- java中Date类型和时间戳、Date和String互转代码
/** * 10位时间戳转Date类型 * @param timeStamp * @return */ public static Date stamp2Date(String timeStamp){ ...
- 2021NOI 省选训练赛day2T1 A. 黑白沙漠
2021NOI 省选训练赛day2T1 A. 黑白沙漠 Problem 在一条长度有限的数轴 \([L,R]\) 上,有 \(N\) 栋建筑物.其中第 \(i\) 栋建筑物的坐标为 \(x_i\) , ...
- stylus - 新生代CSS预处理框架
stylus是什么 Stylus 是一种 CSS 预处理器,它扩展了 CSS 的功能,使得编写样式变得更简洁和高效.Stylus 允许使用嵌套.变量.混入等编程功能,这些功能可以极大地提高开发效率和代 ...
- From Small Not Perfect
自己想实现一个共享文档,然后统计每个人每周做题的数量,然后还想到每个月的统计,每年的统计,哇,好复杂哈 所以我想先做一个Excel,然后开始使用,中间发现了问题,然后调整,修改. 当我做了这个Exce ...
- JIT 编译优化原理深度解析
在 Java 高级程序员面试中,JIT(即时编译,Just-In-Time Compilation)作为提升程序执行效率的核心技术,是 JVM 原理模块的高频考点.本文从 JIT 架构设计.热点代码识 ...
- 【深入理解Spring AOP】核心原理与代理机制详解
深入理解Spring AOP:核心原理与代理机制详解 引言 在现代Java开发中,面向切面编程(AOP)已经成为解决横切关注点的主流方案.作为Spring框架的核心模块之一,Spring AOP通过代 ...
- 有知道CAE软件Hypermesh的配置要求吗?
Altair的Hypermesh是一款先进的有限元分析软件,用于高效地处理和模拟复杂的三维几何形状.作为一款仿真软件,Hypermesh的CPU和GPU配置是非常重要的. 首先,对于Hypermesh ...