题意:给你一些点,求这些点组成的三角形面积最大,而且三角形内不能包含其他点

#include <iostream>
#include <math.h>
#include<stdio.h>
using namespace std; struct Node
{
char c;
int x;
int y;
};
void sort(Node nodes[3], int length)
{
for (int i = 0; i < length; i++)
{
for (int j = 1; j < length - i; j++)
{
if (nodes[j - 1].c > nodes[j].c)
{
Node temp = nodes[j];
nodes[j] = nodes[j - 1];
nodes[j - 1] = temp;
}
}
}
}
double area(double x1, double y1, double x2, double y2, double x3, double y3)
{
double i = (y3 - y1) * (x2 - x1) - (y2 - y1) * (x3 - x1);
return fabs(i) * 0.5;
} int main()
{
while (true)
{
int n;
cin >> n;
if (!n)
return 0;
Node* nodes = new Node[n];
Node res[3];
for (int i = 0; i < n; i++)
{
Node node;
cin >> node.c >> node.x >> node.y;
nodes[i] = node;
}
double maxa = -1;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
for (int k = j + 1; k < n; k++)
{
double a = area(nodes[i].x, nodes[i].y, nodes[j].x,
nodes[j].y, nodes[k].x, nodes[k].y);
if (a <= maxa)
continue;
int contain = false;
for (int t = 0; t < n; t++)
{
if(t == i || t == j || t == k)
continue;
double s1, s2, s3;
s1 = area(nodes[t].x, nodes[t].y, nodes[j].x,
nodes[j].y, nodes[k].x, nodes[k].y); s2 = area(nodes[i].x, nodes[i].y, nodes[t].x,
nodes[t].y, nodes[k].x, nodes[k].y); s3 = area(nodes[i].x, nodes[i].y, nodes[j].x,
nodes[j].y, nodes[t].x, nodes[t].y);
if ((s1 + s2 + s3) == a)
{
contain = true;
break;
}
}
if (!contain)
{
res[0] = nodes[i];
res[1] = nodes[j];
res[2] = nodes[k];
maxa = a;
}
}
}
}
sort(res, 3);
cout << res[0].c << res[1].c << res[2].c << endl;
}
return 0;
}

  

uva-10112-计算几何的更多相关文章

  1. UVa 11796 计算几何

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. UVa 11178计算几何 模板题

    #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #inclu ...

  3. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  4. UVA 12304 - 2D Geometry 110 in 1! - [平面几何基础题大集合][计算几何模板]

    题目链接:https://cn.vjudge.net/problem/UVA-12304 题意: 作为题目大合集,有以下一些要求: ①给出三角形三个点,求三角形外接圆,求外接圆的圆心和半径. ②给出三 ...

  5. UVa 1331 - Minimax Triangulation(区间DP + 计算几何)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  6. uva 11178 Morley&#39;s Theorem(计算几何-点和直线)

    Problem D Morley's Theorem Input: Standard Input Output: Standard Output Morley's theorem states tha ...

  7. Uva 10652 Board Wrapping(计算几何之凸包+点旋转)

    题目大意:给出平面上许多矩形的中心点和倾斜角度,计算这些矩形面积占这个矩形点形成的最大凸包的面积比. 算法:GRAHAM,ANDREW. 题目非常的简单,就是裸的凸包 + 点旋转.这题自己不会的地方就 ...

  8. uva 10652 Board Wrapping (计算几何-凸包)

    Problem B Board Wrapping Input: standard input Output: standard output Time Limit: 2 seconds The sma ...

  9. UVA 10652 Board Wrapping 计算几何

    多边形凸包.. .. Board Wrapping Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu ...

  10. 【UVa】1606 Amphiphilic Carbon Molecules(计算几何)

    题目 题目 分析 跟着lrj学的,理解了,然而不是很熟,还是发上来供以后复习 代码 #include <bits/stdc++.h> using namespace std; ; stru ...

随机推荐

  1. 《DSP using MATLAB》Problem 3.10

    用到了三角窗脉冲序列,各小题的DTFT就不写公式了,直接画图(这里只贴长度M=10的情况). 1. 代码: %% ------------------------------------------- ...

  2. 创意:Soap一款新型的触摸式家用智能路由器

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/iefreer/article/details/34808749 Soap简单介绍 这里的Soap不是 ...

  3. 在浏览器中输入一个URL后都发生了什么

    这道题目没有所谓的完全的正确答案,这个题目可以让你在任意的一个点深入下去, 只要你对这个点是熟悉的.以下是一个大概流程: 浏览器向DNS服务器查找输入URL对应的IP地址. DNS服务器返回网站的IP ...

  4. package.json 文件中的版本号

    版本号,格式:"主要版本,次要版本,补丁版本" 指定版本:比如1.2.2,遵循"主版本,次要版本,补丁版本"的格式规定,安装时只安装指定版本. 波浪号(tild ...

  5. js去除运营商或者路由器添加的广告脚本

    是不是偶尔发现在家里看网页的时候回插入一个广告,很烦人.开发的网站,上传到了阿里云 oss,设置了域名解析,但是在家里晚上访问的时候,总会在页面添加一个广告,导致页面卡主,一开始以为是路由器的问题,以 ...

  6. sysbench 0.5 基准测试

    sysbench 介绍 SysBench是一个模块化的.跨平台.多线程基准测试工具,主要用于评估测试各种不同系统参数下的数据库负载情况.它主要包括以下几种方式的测试: cpu性能 磁盘io性能 调度程 ...

  7. WF4.0 基础篇 (一)开始使用WF

    来源:https://www.cnblogs.com/caosenianhuan/p/WF.html 最近公司要重新上线一套新的CRM系统,要重整老系统里的业务流模块,团队讨论已微软的workflow ...

  8. Spring中IOC与DI的的区别

    依赖注入的前提: 有IOC的环境,也就是将必须对象的创建权交给了Spring. DI 介绍 Dependency Injection 依赖注入.需要有IOC 的环境,Spring 创建这个类的过程中, ...

  9. java工具类-excel jxl

    jxl-2.6.9.14.jarimport net.sf.jxls.transformer.XLSTransformer;//jxls-core-1.0.2.jarimport java.io.Fi ...

  10. chrome从版本55开始,不再支持设置网页内容编码

    Hi Everyone,   Chrome 55 has removed the Encoding menu and Chrome will do auto-encoding detection no ...