HDU4082(相似三角形的个数)
  nN9d1Biy3lFP 2023年11月02日 44 0


题目:Hou Yi's secret

 

#include<stdio.h>
#include<math.h>
#include<map>
#include<iostream>
#include<string.h>
using namespace std;
const double eps=1e-6;
map<long long,int>mp;
struct Node
{
    int x,y;
}node[50];

double dis(Node a,Node b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

void solve(Node a,Node b,Node c)
{
    double la=dis(b,c);
    double lb=dis(a,c);
    double lc=dis(a,b);
    if(la+lb<=lc+eps)return;
    if(lb+lc<=la+eps)return;
    if(la+lc<=lb+eps)return;
    double A=acos((lb*lb+lc*lc-la*la)/(2*lb*lc));
    double B=acos((la*la+lc*lc-lb*lb)/(2*la*lc));
    double C=acos((la*la+lb*lb-lc*lc)/(2*la*lb));
    if(A<eps||B<eps||C<eps)return;
    int t1=(int)(A*10000);
    int t2=(int)(B*10000);
    int t3=(int)(C*10000);
    if(t1>t2)swap(t1,t2);
    if(t1>t3)swap(t1,t3);
    if(t2>t3)swap(t2,t3);
    if(t1==0)return;
    long long t=t1*1000000*1000000+t2*1000000+t3;
    mp[t]++;
}

int hole[220][220];

int main ()
{
    int n;
    while(scanf("%d",&n),n)
    {
        int t=0;
        memset(hole,0,sizeof(hole));
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&node[t].x,&node[t].y);
            if(hole[node[t].x+100][node[t].y+100]==0)
            {
                hole[node[t].x+100][node[t].y+100]=1;
                t++;
            }
        }
        n=t;
        mp.clear();
        for(int i=0;i<n;i++)
          for(int j=i+1;j<n;j++)
            for(int k=j+1;k<n;k++)
              solve(node[i],node[j],node[k]);
        int ans=0;
        map<long long,int>::iterator it;
        for(it=mp.begin();it!=mp.end();it++)
        {
            int t=it->second;
            if(t>ans)ans=t;
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  HE3leaVn7jMN   2023年11月24日   31   0   0 Timei++#include
  HE3leaVn7jMN   2023年11月26日   30   0   0 i++#include
nN9d1Biy3lFP