zoukankan      html  css  js  c++  java
  • 华东交通大学2015年ACM“双基”程序设计竞赛1001

    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
    ",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;
    }
    

      

  • 相关阅读:
    $(document).ready(function(){}) 与 window.onload = function(){} 区别
    [如何在Mac下使用gulp] 1.创建项目及安装gulp
    Mac 执行 gulp 报错 bash: gulp: command not found
    css 字体单位之间的区分以及字体响应式实现
    [nodejs]在mac环境下如何将node更新至最新?
    [angular 1.x] 使用select 实现下拉列表 ngoptions 与 ngrepeat的取舍
    事件冒泡、事件捕获、事件委托初探
    Android 随机铃声管理器
    git 强制恢复到某一版本
    混乱中生存
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/5003100.html
Copyright © 2011-2022 走看看