Problem A

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 745   Accepted Submission(s) : 89

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

给定两个三角形,判断两个三角形是否相似。
注意6个点的坐标严格两两不重合,并且肯定能组成三角形。
请注意,由于测试数据有多组,主函数可采用如下格式。
#include<stdio.h>
……
int main()
{
while(scanf() != EOF)
{
……
}
return 0;
}

Input

多组测试数据输入(200组左右)。
输入 6个点的坐标x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,前三个点表示第一个三角形的坐标,后三个点表示第二个三角形的坐标。
(1<=xi<=100,1<=yi<=100,xi,yi为int型)

Output

如果两个三角形相似输出Yes,否则输出No

Sample Input

0 1
1 1
1 0
4 3
3 3
3 4

Sample Output

Yes

Author

moonlike
 
我们把它们六条边算出来,然后排序,最小/另一个最小=比值=三角形周长/另外一个三角形周长(精度我是取1e-6)
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
double x1,y1,x2,y2,x3,y3;
double x4,y4,x5,y5,x6,y6;
double dis(double x_1,double y_1,double x_2,double y_2)
{
return sqrt((x_1-x_2)*(x_1-x_2)+(y_1-y_2)*(y_1-y_2));
}
int main()
{
double d[3];
double e[3];
double r1,r2;
while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4>>x5>>y5>>x6>>y6)
{
d[0]=dis(x1,y1,x2,y2);
d[1]=dis(x1,y1,x3,y3);
d[2]=dis(x2,y2,x3,y3);
e[0]=dis(x4,y4,x5,y5);
e[1]=dis(x4,y4,x6,y6);
e[2]=dis(x5,y5,x6,y6);
sort(d,d+3);
sort(e,e+3);
// cout<<d[0]<<endl;
// cout<<e[0]<<endl;
// printf("%f\n",d[0]/e[0]);
r1=(double)d[0]/e[0]*1.0;
r2=(double)(d[0]+d[1]+d[2])/(e[0]+e[1]+e[2])*1.0;
if(abs(r1-r2)<=1e-6)
{
puts("Yes");
}
else
{
puts("No");
}
}
return 0;
}

  

华东交通大学2015年ACM“双基”程序设计竞赛1001的更多相关文章

  1. 华东交通大学2015年ACM“双基”程序设计竞赛1002

    Problem B Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Sub ...

  2. 华东交通大学2015年ACM“双基”程序设计竞赛1007

    Problem G Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Sub ...

  3. 华东交通大学2015年ACM“双基”程序设计竞赛1003

    Problem C Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Sub ...

  4. 华东交通大学2015年ACM“双基”程序设计竞赛1005

    Problem E Time Limit : 3000/2000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Sub ...

  5. 华东交通大学2015年ACM“双基”程序设计竞赛1004

    Problem D Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Sub ...

  6. 华东交通大学2016年ACM“双基”程序设计竞赛 1001

    Problem Description 输入一个非负的int型整数,是奇数的话输出"ECJTU",是偶数则输出"ACM". Input 多组数据,每组数据输入一 ...

  7. 华东交通大学2017年ACM“双基”程序设计竞赛 1001

    Problem Description 最近流行吃鸡,那就直接输出一行"Winner winner ,chicken dinner!"(没有双引号)模板代码:#include &l ...

  8. 华东交通大学2018年ACM“双基”程序设计竞赛 C. 公式题 (2) (矩阵快速幂)

    题目链接:公式题 (2) 比赛链接:华东交通大学2018年ACM"双基"程序设计竞赛 题目描述 令f(n)=2f(n-1)+3f(n-2)+n,f(1)=1,f(2)=2 令g(n ...

  9. 华东交通大学2018年ACM“双基”程序设计竞赛部分题解

    链接:https://ac.nowcoder.com/acm/contest/221/C来源:牛客网 C-公式题(2) 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其 ...

随机推荐

  1. Comparatable接口和Comparator接口的使用与区别

    这篇博文可以为你解决的问题如下: 什么是自然排序 Collections.sort()与Arrays.sort()的异同点 Comparatable接口和Comparator接口各自的排序依据(理论讲 ...

  2. SpringJdbc 【springjdbc的使用方法】

    1 什么是springjdbc spring对jdbc的封装 2 使用SpringJdbc的编程步骤 2.1 导包 spring-jdbc : springjdbc的包 mysql : MySQL的驱 ...

  3. Damn Couples ZOJ - 3161

    传送门 题目大意 N个人,M组关系,每次选一种关系,如果两个人相邻,则任意删除其中一个,否则不变.问最坏情况下最多能剩多少人. 分析 为了留的人最多,我们可以先将原来不相邻的关系全部说完,这样我们只需 ...

  4. js定时任务

    <input type="button" id="btn" value="保存图片" onclick="settime(th ...

  5. virtualbox复制虚拟机网络问题

    virtulbox复制虚拟机由于mac地址问题会导致网卡不可以用 1:修改mac地址 需要在virtualbox修改虚拟机网络选项卡下面的mac地址 2:修改ifcfg-eth0 把HWADDR的值设 ...

  6. xe6 android控件透明度设置方法

    今天才知道xe6 android控件的透明度设置方法:只需设置控件中的Opacity参数,默认为1--不透明 panel1.Opacity:=0.60;

  7. Spring 第一个程序-Bean的定义和注册

    定义一个实现接口的方法 创建xml文件,这个xml文件就是个所谓的容器         不使用spring容器和使用spring容器创建对象执行代码的区别如下:   下面说一下ApplicationC ...

  8. Java50道经典习题-程序31 数组逆序

    题目:将一个数组逆序输出.分析:用第一个与最后一个交换. public class Prog31 { public static void main(String[] args) { //遍历原始数组 ...

  9. maven-排除传递依赖-exclusions

    在maven项目中引用dubbo的maven依赖的时候会引入dubbo中传递依赖的spring的依赖包如下:         <!-- dubbo相关的jar包 -->        &l ...

  10. ueditor UEditor的setContent的时候报错

    今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.body is undefined 或 Uncaught TypeError: Cannot set ...