http://acm.fzu.edu.cn/problem.php?pid=2270

【题意】

给定6到10个点,从中选出6个不同的点组成两个三角形,使其中一个三角形可以通过另一个三角形平移和旋转得到。问有多少种不同的三角形选法?

【思路】

  • 全等
  • 排除对称

【Accepted】

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std; int n;
const double eps=1e-;
struct Point
{
int x;
int y;
Point(){}
Point(int _x,int _y):x(_x),y(_y){}
Point operator-(const Point &b)const
{
return Point(x-b.x,y-b.y);
}
int operator^(const Point &b)const
{
return x*b.y-y*b.x;
}
int operator*(const Point &b)const
{
return x*b.x+y*b.y;
}
}p[];
bool v[][][][][][];
int dist(int i,int j)
{
return (p[i]-p[j])*(p[i]-p[j]);
}
int dis[][];
bool judge(int i,int j,int k)
{
double x=sqrt(dist(i,j));
double y=sqrt(dist(i,k));
double z=sqrt(dist(j,k));
double a[]={x,y,z};
sort(a,a+);
if(fabs(a[]+a[]-a[])<=eps)
{
return false;
}
return true;
} bool check(int i,int j,int k,int l,int m,int o,int flag)
{
int a[]={i,k,m};
int b[]={j,l,o};
sort(a,a+);
sort(b,b+);
if(v[a[]][a[]][a[]][b[]][b[]][b[]])
{
return true;
}
if(flag)
{
v[a[]][a[]][a[]][b[]][b[]][b[]]=;
}
return false;
} bool rt(int i,int j,int k,int l,int m,int o)
{
if(((p[k]-p[i])^(p[m]-p[k]))*((p[l]-p[j])^(p[o]-p[l]))<)//叉积的乘积大于等于0代表方向是一样的,如果方向不一样,说明是对称的
{
return false;
}
if(((p[m]-p[k])^(p[i]-p[m]))*((p[o]-p[l])^(p[j]-p[o]))<)
{
return false;
}
if(((p[i]-p[m])^(p[k]-p[i]))*((p[j]-p[o])^(p[l]-p[j]))<)
{
return false;
}
return true;
}
int main()
{
int T;
scanf("%d",&T);
int cas=;
while(T--)
{
//这个数组用来去重,一定要初始化
memset(v,,sizeof(v));
int ans=;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
}
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(j==i) continue;
for(int k=;k<=n;k++)
{
if(k==i||k==j) continue;
for(int l=;l<=n;l++)
{
if(l==i||l==j||l==k) continue;
if(dist(i,k)!=dist(j,l)) continue;
//目前为止已经选出两个三角形对应相等的两条边ik和jl
for(int m=;m<=n;m++)
{
if(m==i||m==j||m==k||m==l) continue;
//先选出m点,排除三点共线的情况
if(!judge(i,k,m)) continue;
for(int o=;o<=n;o++)
{
if(o==i||o==j||o==k||o==l||o==m) continue;
if(dist(k,m)!=dist(l,o)||dist(m,i)!=dist(o,j)) continue;
//现在已经选出两个全等的三角形
if(check(i,j,k,l,m,o,)) continue;
//去重,如果是重复的重新选择
if(rt(i,j,k,l,m,o))//因为只能是平移和旋转得到,所以要排除对称这种情况
{
ans++;
check(i,j,k,l,m,o,);//把这种选择标记为1
}
}
}
}
}
}
}
printf("Case %d: %d\n",++cas,ans);
}
return ;
}

【计算几何】FZU Problem 2270 Two Triangles的更多相关文章

  1. FZu Problem 2233 ~APTX4869 (并查集 + sort)

    题目链接: FZu Problem 2233 ~APTX4869 题目描述: 给一个n*n的矩阵,(i, j)表示第 i 种材料 和 第 j 种材料的影响值,这个矩阵代表这n个物品之间的影响值.当把这 ...

  2. FZu Problem 2236 第十四个目标 (线段树 + dp)

    题目链接: FZu  Problem 2236 第十四个目标 题目描述: 给出一个n个数的序列,问这个序列内严格递增序列有多少个?不要求连续 解题思路: 又遇到了用线段树来优化dp的题目,线段树节点里 ...

  3. 翻翻棋(找规律问题)(FZU Problem 2230)

    题目是这样的: FZU Problem 2230 象棋翻翻棋(暗棋)中双方在4*8的格子中交战,有时候最后会只剩下帅和将.根据暗棋的规则,棋子只能上下左右移动,且相同的级别下,主动移动到地方棋子方将吃 ...

  4. fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...

  5. fzu Problem 2140 Forever 0.5(推理构造)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2140 题意: 题目大意:给出n,要求找出n个点,满足: 1)任意两点间的距离不超过1: 2)每个点与(0,0)点的 ...

  6. Fzu Problem 2082 过路费 LCT,动态树

    题目:http://acm.fzu.edu.cn/problem.php?pid=2082 Problem 2082 过路费 Accept: 528    Submit: 1654Time Limit ...

  7. FZU Problem 2169 shadow

    http://acm.fzu.edu.cn/problem.php?pid=2169 题目大意: S王国有N个城市,有N-1条道路.王都为编号1的城市.叛军驻扎在很多城市.除了王都外有K个城市有军队, ...

  8. fzu Problem 2128 最长子串(KMP + strstr 经典好题)

     Problem Description 问题很简单,给你一个字符串s,问s的子串中不包含s1,s2...sn的最长串有多长.  Input 输入包含多组数据.第一行为字符串s,字符串s的长度1到10 ...

  9. fzu Problem - 2232 炉石传说(二分匹配)

    题目链接:http://acm.fzu.edu.cn/problem.php?pid=2232 Description GG学长虽然并不打炉石传说,但是由于题面需要他便学会了打炉石传说.但是传统的炉石 ...

随机推荐

  1. AJPFX总结I/O流操作(一)

    在软件开发中,数据流和数据库操作占据了一个很重要的位置,所以,熟悉操作数据流和数据库,对于每一个开发者来说都是很重要的,今天就来总结一下I/O,数据库操作 一:从数据流开始 首先先有一个结构图看一下整 ...

  2. LN : leetcode 215 Kth Largest Element in an Array

    lc 215 Kth Largest Element in an Array 215 Kth Largest Element in an Array Find the kth largest elem ...

  3. Day01 计算机硬件基础

    1.什么是编程语言? 编程语言是程序员与计算机沟通的介质. 2.什么是编程? 程序员利用某种编程语言的语法格式将自己脑子中想要让计算机做的事写到文件中. 所以说,变成的结果就是文件,文件的内容就是一堆 ...

  4. logging日志过滤和日志文件自动截取

    1.日志过滤 import logging class IgnoreFilter(logging.Filter): def filter(self,record): return "girl ...

  5. [ SNOI 2013 ] Quare

    Description 题目链接 求一张无向带权图的边双连通生成子图的最小代价. Solution 核心的思路是,一个点双连通分量肯定是一堆环的并. 考虑增量地构造这个边双连通图,每次把一个环并进去, ...

  6. 自定义Toast的显示位置和显示内容

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  7. Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:jar:2.5.1

    Mac上写了一段基于Maven的java代码. 上传Git后,在windows上pull下来,eclipse里面各种错误. ArtifactTransferException:Failure to t ...

  8. Phalcon初认识

    Phalcon以c扩展交付的全堆栈php开发框架 基本功能 低开销:低内存消耗和CPU相比传统的框架 MVC和HMVC:模块.组件.模型.视图和控制器 依赖注入:依赖注入和位置的服务和它的本身他们的容 ...

  9. Photoshop 注册破解

    本机测试环境为Photoshop cs4 破解方式一: 打开C:\windows\system32\drivers\etc\"找到 hosts 文件, 右键点击--打开方式---记事本,然后 ...

  10. 洛谷 P2604 [ZJOI2010]网络扩容

    题目描述 给定一张有向图,每条边都有一个容量C和一个扩容费用W.这里扩容费用是指将容量扩大1所需的费用.求: 1. 在不扩容的情况下,1到N的最大流: 2. 将1到N的最大流增加K所需的最小扩容费用. ...