zoukankan      html  css  js  c++  java
  • Two Triangles FZU

    题目链接:

    https://cn.vjudge.net/problem/FZU-2270

    题目大意:

    给你n个点,然后每一次你从中选三个点,另一个人再选三个。在都能构成三角形的条件下,如果这两个三角形能通过平移,旋转和另外一个三角形完全重合,贡献加1,问你最终能有多少贡献?

    具体思路:

    延亮的思路,学习下

    六个for循环枚举。

    具体检验的时候,首先判断能不能构成三角形;然后分别对两个 三角形的三个向量进行极角排序,每一次比较的按照顺时针方向比较就好了。

    https://www.cnblogs.com/aiguona/p/7248311.html

    极角排序,给定平面上的一些点,把它们按照一个选定的中心点排成顺(逆)时针。

    AC代码:

      1 #include<iostream>
      2 #include<stdio.h>
      3 #include<cmath>
      4 #include<algorithm>
      5 #include<string>
      6 #include<cstring>
      7 # define ll long long
      8 # define inf 0x3f3f3f3f
      9 # define ull unsigned long long
     10 using namespace std;
     11 const int maxn = 2e5+100;
     12 struct node{int x,y;} q[maxn];
     13 struct Edge{
     14 int x,y;
     15 int dis;
     16 Edge(){}
     17 Edge(int xx,int yy,int zz){
     18 x=xx;
     19 y=yy;
     20 dis=zz;
     21 }
     22 };
     23 double sto1[4],sto2[4];
     24 double dis1(int t1,int t2){
     25 return sqrt((q[t1].x-q[t2].x)*(q[t1].x-q[t2].x)*1.0+(q[t1].y-q[t2].y)*(q[t1].y-q[t2].y)*1.0);
     26 }
     27 int dis2(int t1,int t2){
     28 return (q[t1].x-q[t2].x)*(q[t1].x-q[t2].x)+(q[t1].y-q[t2].y)*(q[t1].y-q[t2].y);
     29 }
     30 bool cmp(Edge t1,Edge t2){// 极角排序
     31 return (t1.x*t2.y)-(t1.y*t2.x)>0;
     32 }
     33 bool check(int a,int b,int c,int d,int e,int f){
     34 sto1[1]=dis1(a,b);
     35 sto1[2]=dis1(b,c);
     36 sto1[3]=dis1(c,a);
     37 sto2[1]=dis1(d,e);
     38 sto2[2]=dis1(e,f);
     39 sto2[3]=dis1(f,d);
     40 
     41 sort(sto1+1,sto1+1+3);
     42 sort(sto2+1,sto2+1+3);
     43 
     44 if(sto1[1]+sto1[2]<=sto1[3])return false;
     45 if(sto2[1]+sto2[2]<=sto2[3])return false;/// compose triangle
     46 
     47 Edge tmp1[4],tmp2[4];
     48 
     49 tmp1[1]=Edge(q[a].x-q[b].x,q[a].y-q[b].y,dis2(a,b));
     50 tmp1[2]=Edge(q[b].x-q[c].x,q[b].y-q[c].y,dis2(b,c));
     51 tmp1[3]=Edge(q[c].x-q[a].x,q[c].y-q[a].y,dis2(c,a));
     52 
     53 tmp2[1]=Edge(q[d].x-q[e].x,q[d].y-q[e].y,dis2(d,e));
     54 tmp2[2]=Edge(q[e].x-q[f].x,q[e].y-q[f].y,dis2(e,f));
     55 tmp2[3]=Edge(q[f].x-q[d].x,q[f].y-q[d].y,dis2(f,d));
     56 
     57 sort(tmp1+1,tmp1+1+3,cmp);
     58 sort(tmp2+1,tmp2+1+3,cmp);
     59 
     60 if(tmp1[1].dis==tmp2[1].dis&&tmp1[2].dis==tmp2[2].dis&&tmp1[3].dis==tmp2[3].dis)return true;
     61 if(tmp1[1].dis==tmp2[2].dis&&tmp1[2].dis==tmp2[3].dis&&tmp1[3].dis==tmp2[1].dis)return true;
     62 if(tmp1[1].dis==tmp2[3].dis&&tmp1[2].dis==tmp2[1].dis&&tmp1[3].dis==tmp2[2].dis)return true;
     63 return false;
     64 }
     65 int a[10];
     66 int main()
     67 {
     68     int T,Case=0;
     69     scanf("%d",&T);
     70     while(T--)
     71     {
     72         int n;
     73         int ans=0;
     74         scanf("%d",&n);
     75         for(int i=1; i<=n; i++)
     76         {
     77             scanf("%d %d",&q[i].x,&q[i].y);
     78         }
     79         for(int i=1; i<=n; i++)
     80         {
     81             for(int j=i+1; j<=n; j++)
     82             {
     83                 for(int k=j+1; k<=n; k++)
     84                 {
     85                     for(int w=1; w<=n; w++)
     86                     {
     87                         for(int L=w+1; L<=n; L++)
     88                         {
     89                             for(int J=L+1; J<=n; J++)
     90                             {
     91                                 a[1]=i;
     92                                 a[2]=j;
     93                                 a[3]=k;
     94                                 a[4]=w;
     95                                 a[5]=L;
     96                                 a[6]=J;
     97                                 sort(a+1,a+6+1);
     98                                 int flag=1;
     99                                 for(int q=2; q<=6; q++)
    100                                 {
    101                                     if(a[q]==a[q-1])
    102                                     {
    103                                         flag=0;
    104                                         break;
    105                                     }
    106                                 }
    107                                 if(!flag)
    108                                 continue;
    109                                 if(check(i,j,k,w,L,J))
    110                                     ans++;
    111                             }
    112                         }
    113                     }
    114                 }
    115             }
    116         }
    117         printf("Case %d: %d
    ",++Case,ans);
    118     }
    119     return 0;
    120 }

     

     

  • 相关阅读:
    顧客満足度調査
    GeoStTool.dll过滤图层
    GeoStTool.ini相关技术要点
    GeoStTool.dll与RasterServer通信
    hdu 1007 Quoit Design
    hdu 4325 Flowers
    hdu 2516 取石子游戏
    hdu 1006 Tick and Tick
    CodeForces 101A Homework
    ZOJ Problem Set 1879
  • 原文地址:https://www.cnblogs.com/letlifestop/p/10994862.html
Copyright © 2011-2022 走看看