zoukankan      html  css  js  c++  java
  • poj1244Slots of Fun

    链接

    几何的简单题,建立坐标,判断相等以及不共线

      1 #include <iostream>
      2 #include<cstdio>
      3 #include<cstring>
      4 #include<algorithm>
      5 #include<stdlib.h>
      6 #include<vector>
      7 #include<cmath>
      8 #include<queue>
      9 #include<set>
     10 using namespace std;
     11 #define N 200
     12 #define LL long long
     13 #define INF 0xfffffff
     14 const double eps = 1e-8;
     15 const double pi = acos(-1.0);
     16 const double inf = ~0u>>2;
     17 char s[N],sr[30];
     18 struct Point
     19 {
     20     double x,y;
     21     Point(double x=0,double y=0):x(x),y(y) {}
     22 }p[N];
     23 vector<Point>ed[30];
     24 typedef Point pointt;
     25 pointt operator + (Point a,Point b)
     26 {
     27     return Point(a.x+b.x,a.y+b.y);
     28 }
     29 pointt operator - (Point a,Point b)
     30 {
     31     return Point(a.x-b.x,a.y-b.y);
     32 }
     33 int dcmp(double x)
     34 {
     35     if(fabs(x)<eps) return 0;
     36     else return x<0?-1:1;
     37 }
     38 double dis(Point a)
     39 {
     40     return sqrt(a.x*a.x+a.y*a.y);
     41 }
     42 double cross(Point a,Point b)
     43 {
     44     return a.x*b.y-a.y*b.x;
     45 }
     46 double mul(Point p0,Point p1,Point p2)
     47 {
     48     return cross(p1-p0,p2-p0);
     49 }
     50 int main()
     51 {
     52     int n,i,j,g,e;
     53     while(scanf("%d",&n)&&n)
     54     {
     55         getchar();
     56         for(i = 0; i < 26 ; i++)
     57         ed[i].clear();
     58         for(i = 1 ; i <= n*(n+1)/2; i++)
     59         scanf("%c",&s[i]);
     60         int g = 0;
     61         double tx=n,ty = sqrt(3.0)*(n-1);
     62         for(i = 1 ;i <= n; i++)
     63         {
     64             double x0 = tx-i+1;
     65             double y0 = ty-(i-1)*sqrt(3.0);
     66             for(j = 1; j <= i ;j++)
     67             {
     68                 Point pp;
     69                 pp.y = y0;
     70                 pp.x = x0;
     71                 x0+=2;
     72                 g++;
     73                 ed[s[g]-'a'].push_back(pp);
     74             }
     75         }
     76         int cnt = 0;
     77         for(i = 0; i < 26 ; i++)
     78         {
     79             if(ed[i].size()<3) continue;
     80             int k = ed[i].size();
     81             for(j = 0 ;j < k ; j++)
     82                 for(g = j+1 ; g < k ; g++)
     83                     for(e = g+1 ; e < k ; e++)
     84                     {
     85                         Point p1 = ed[i][j],p2 = ed[i][g],p3 = ed[i][e];
     86 //                        cout<<p1.x<<" "<<p1.y<<" "<<p2.x<<" "<<p2.y<<" "<<p3.x<<" "<<p3.y<<endl;
     87 //                        cout<<i<<" "<<dis(p1-p2)<<" "<<dis(p1-p3)<<" "<<dis(p2-p3)<<endl;
     88                         if(dcmp(dis(p1-p2)-dis(p1-p3))==0&&dcmp(dis(p1-p2)-dis(p2-p3))==0&&dcmp(mul(p1,p2,p3))!=0)
     89                         {
     90                             sr[cnt++] = i+'a';
     91                         }
     92                     }
     93         }
     94         if(cnt==0)
     95         {
     96             puts("LOOOOOOOOSER!");
     97             continue;
     98         }
     99         for(i = 0 ; i < cnt ; i++)
    100         printf("%c",sr[i]);
    101         puts("");
    102     }
    103     return 0;
    104 }
    View Code
  • 相关阅读:
    JQUERY获取text,areatext,radio,checkbox,select值(转)
    如何查看oracle sql执行计划
    Silverlight资源整理
    ORACLE分页SQL语句
    百科名片SEO
    转 JQuery FlexiGrid的asp.net完美解决方案:dotNetFlexGrid 源码、文档、范例程序下载。
    清除SQLServer2005的LOG文件
    GridView EmptyDataText Border
    Uploading Files in ASP.NET 2.0
    Invalid postback or callback argument.
  • 原文地址:https://www.cnblogs.com/shangyu/p/3821601.html
Copyright © 2011-2022 走看看