福建省第八届 Triangles
Problem Description
This is a simple problem. Given two triangles A and B, you should determine they are intersect, contain or disjoint. (Public edge or point are treated as intersect.)
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: X1 Y1 X2 Y2 X3 Y3 X4 Y4 X5 Y5 X6 Y6. All the coordinate are integer. (X1,Y1) , (X2,Y2), (X3,Y3) forms triangles A ; (X4,Y4) , (X5,Y5), (X6,Y6) forms triangles B.
-10000<=All the coordinate <=10000
Output
For each test case, output “intersect”, “contain” or “disjoint”.
Sample Input
Sample Output


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int t,ans;
struct point
{
double x;
double y;
};
struct trangle
{
point p[];
}angle[];
double area(point a,point b,point c)
{
return fabs((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y));//三角形面积
}
bool check(trangle a,trangle b)
{
double area_trangle=area(a.p[],a.p[],a.p[]);//判断是否包含和不相交
int pos=;
for(int i=;i<;i++)
{
if((area(b.p[i],a.p[],a.p[])+area(b.p[i],a.p[],a.p[])+area(b.p[i],a.p[],a.p[]))>area_trangle) continue;
else ans++,pos++;
}
return pos==;
}
void solve()
{
ans=;
if(check(angle[],angle[]) || check(angle[],angle[]))
{
puts("contain");
return ;
}
else if(!ans)
{
puts("disjoint");
return ;
}
else
{
puts("intersect");
return ;
}
}
int main()
{
scanf("%d",&t);
while(t--)
{
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
scanf("%lf%lf",&angle[i].p[j].x,&angle[i].p[j].y);
}
}
solve();
}
return ;
}
福建省第八届 Triangles的更多相关文章
- FZU 2273 Triangles 第八届福建省赛 (三角形面积交 有重边算相交)
Problem Description This is a simple problem. Given two triangles A and B, you should determine they ...
- FZU 2272 Frog 第八届福建省赛 (鸡兔同笼水题)
Problem Description Therearex frogs and y chicken in a garden. Kim found there are n heads and m leg ...
- FOJ Problem 2273 Triangles
Problem 2273 Triangles Accept: 201 Submit: 661Time Limit: 1000 mSec Memory Limit : 262144 KB P ...
- FZUOJ-2273 Triangles
Problem 2273 Triangles Accept: 109 Submit: 360 Time Limit: 1000 mSec Memory Limit : 262144 KB ...
- Count the number of possible triangles
From: http://www.geeksforgeeks.org/find-number-of-triangles-possible/ Given an unsorted array of pos ...
- 电子科技大学第八届ACM趣味程序设计竞赛第四场(正式赛)题解
A. Picking&Dancing 有一列n个石子,两人交替取石子,每次只能取连续的两个,取走后,剩下的石子仍然排成1列.问最后剩下的石子数量是奇数还是偶数. 读懂题意就没什么好说的. #i ...
- [ACM_搜索] Triangles(POJ1471,简单搜索,注意细节)
Description It is always very nice to have little brothers or sisters. You can tease them, lock them ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- UVA 12651 Triangles
You will be given N points on a circle. You must write a program to determine how many distinctequil ...
随机推荐
- !HDU 2602 Bone Collector--DP--(裸01背包)
题意:这题就是一个纯粹的裸01背包 分析:WA了好几次.01背包实现的一些细节没搞懂 1.为什么dp[i][j]赋初值为0而不是value[i].由于第i个石头可能不放! 2.在进行状态转移之前要dp ...
- IIS Modules Overview
Introduction The IIS 7 and above Web server feature set is componentized into more than thirty indep ...
- Firefox访问https的网站,一直提示不安全
http://mozilla.com.cn/thread-374897-1-1.html 要激活此功能步骤如下: 在地址栏键入"about:config" 点击“我了解此风险” 在 ...
- “DNS隧道”盗号木马分析——类似hjack偷密码然后利用dns tunnel直传数据发送出去
摘自:http://www.freebuf.com/articles/network/38276.html# 运行后不断监控顶端窗口,一旦发现为QQ,就弹出一个自己伪造的QQ登陆窗口,诱导用户输入密码 ...
- Rapidjson的简单使用示例
很早就想用用Markdown了,一直没机会.今天就来试一下 先放个目录: Rapidjson的简单使用示例 rapidjson官方教程 本示例所用环境 示例代码与注释 rapidjson官方教程 如果 ...
- 26. Intellij IDEA 启动项目ClassNotFoundException
转自:https://blog.csdn.net/zhw0596/article/details/81388147 使用Intellij IDEA 的过程中,新创建的项目启动时报 严重: Error ...
- js易错点总结及 常见面试的坑
最近在研究Javascript发现了其中一些比较灵异的事情.有点让人感到无语比如: var arr = [], arr2 = {}; console.log(typeof(arr) === typeo ...
- Gym - 100637A Nano alarm-clocks 模拟
题意:有n个时钟,只能顺时针拨,问使所有时间相同的最小代价是多少 思路:将时间排序,枚举拨动到每一个点的时间就好了,容易证明最终时间一定是其中之一 #include <iostream> ...
- HDU 4349 Xiao Ming's Hope 组合数学
题意:给你n,问在C(n,1),C(n,2)...C(n,n)中有多少个奇数. 比赛的时候打表看出规律,这里给一个数学上的说明. Lucas定理:A,B非负整数,p是质数,A,B化为p进制分别为a[n ...
- 【转载】jQuery弹出层始终垂直居中于当前屏幕
一般网站上肯定有一些弹出框,不论弹出框的大小,都需要他在当前窗口垂直居中.之前手上就有一个jQuery的例子,后来才发现,他只能在第一屏垂直居中,如果滑动滚动条,弹出的框就在上方,不是很方便.请教朋友 ...