福建省第八届 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 ...
随机推荐
- python的开发工具UliPad安装篇
之前文章里写过一个搭建windows下搭建Selenium+Eclipse+Python环境,如今认为这个Eclipse太大了,太笨重了,重新启动又慢,像Python脚本轻级语言,不是必需用那么大的工 ...
- 用三层交换建立企业VLAN
650) this.width=650;" onclick='window.open("http://blog.51cto.com/viewpic.php?refimg=" ...
- vue 指令的用法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- MD markdown入门
1.Headings: 2.Phrase emphasis *italic text* **Bold text** 3.Listing items (在文字之前添加 + , - 或者 * ) -ite ...
- JS之字符串和数组
字符串: 属性: length:可以获取字符串的长度: <script type="text/javascript"> var str = "haha&quo ...
- 基于promise用于浏览器和node.js的http客户端的axios
axios 是一个基于Promise 用于浏览器和 nodejs 的 HTTP 客户端,它本身具有以下特征: 从浏览器中创建 XMLHttpRequest 从 node.js 发出 http 请求 支 ...
- HDU 1668 Islands and Bridges
Islands and Bridges Time Limit: 4000ms Memory Limit: 65536KB This problem will be judged on HDU. Ori ...
- ajax动态更新下拉列表
前面做了一个ajax的小demo,今天看一个动态更新下拉列表,或者也叫级联更新下拉列表,这个也是利用ajax的异步调用去后台实现数据请求.然后回到前台完毕下拉列表数据的更新,以增强web应用的交互性. ...
- 淘宝在hbase中的应用和优化
本文来自于NoSQLFan联合作者@koven2049,他在淘宝从事Hadoop及HBase相关的应用和优化. 对Hadoop.HBase都有深入的了解,本文就是其在工作中对HBase的应用优化小结, ...
- 深入分析JavaWeb Item23 -- jsp自己定义标签开发入门
一.自己定义标签的作用 自己定义标签主要用于移除Jsp页面中的java代码. 二.自己定义标签开发和使用 2.1.自己定义标签开发步骤 1.编写一个实现Tag接口的Java类(标签处理器类) 要编写一 ...