链接

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

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 200
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
char s[N],sr[];
struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y) {}
}p[N];
vector<Point>ed[];
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
double dis(Point a)
{
return sqrt(a.x*a.x+a.y*a.y);
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double mul(Point p0,Point p1,Point p2)
{
return cross(p1-p0,p2-p0);
}
int main()
{
int n,i,j,g,e;
while(scanf("%d",&n)&&n)
{
getchar();
for(i = ; i < ; i++)
ed[i].clear();
for(i = ; i <= n*(n+)/; i++)
scanf("%c",&s[i]);
int g = ;
double tx=n,ty = sqrt(3.0)*(n-);
for(i = ;i <= n; i++)
{
double x0 = tx-i+;
double y0 = ty-(i-)*sqrt(3.0);
for(j = ; j <= i ;j++)
{
Point pp;
pp.y = y0;
pp.x = x0;
x0+=;
g++;
ed[s[g]-'a'].push_back(pp);
}
}
int cnt = ;
for(i = ; i < ; i++)
{
if(ed[i].size()<) continue;
int k = ed[i].size();
for(j = ;j < k ; j++)
for(g = j+ ; g < k ; g++)
for(e = g+ ; e < k ; e++)
{
Point p1 = ed[i][j],p2 = ed[i][g],p3 = ed[i][e];
// cout<<p1.x<<" "<<p1.y<<" "<<p2.x<<" "<<p2.y<<" "<<p3.x<<" "<<p3.y<<endl;
// cout<<i<<" "<<dis(p1-p2)<<" "<<dis(p1-p3)<<" "<<dis(p2-p3)<<endl;
if(dcmp(dis(p1-p2)-dis(p1-p3))==&&dcmp(dis(p1-p2)-dis(p2-p3))==&&dcmp(mul(p1,p2,p3))!=)
{
sr[cnt++] = i+'a';
}
}
}
if(cnt==)
{
puts("LOOOOOOOOSER!");
continue;
}
for(i = ; i < cnt ; i++)
printf("%c",sr[i]);
puts("");
}
return ;
}

poj1244Slots of Fun的更多相关文章

随机推荐

  1. postgresql 热备与恢复

    一. PostgreSQL热备份的过程一般为: 数据库中执行:pg_start_backup() ; 然后使用操作系统的tar或 cp命令拷贝 PostgreSQL数据文件. 数据库中执行:pg_st ...

  2. 约瑟夫问题 java

    约瑟夫环:已知n个人(以编号1,2,3...n分别表示)围坐在一张圆桌周围.从编号为k的人开始报数,数到m的那个人出列;他的下一个人又从1开始报数,数到m的那个人又出列;依此规律重复下去,直到圆桌周围 ...

  3. Mybaits 之根据集合查询和逗号分隔的子查询

    这是我们的mapper要根据传入一个集合进行查询: List<ExtKeywordCategory> findListByIds(List<ExtKeywordFkCategory& ...

  4. 软件密码和https协议

    密码安全问题,一直是程序员最痛疼的问题,这一章主要的来说一下密码的安全,和怎么提高密码的安全,还有Tomcat的https协议. 密码对于一个程序的安全有多重要就不多说了,如果你做过银行系统的话,那么 ...

  5. 在nginx下去掉ci框架url中的index.php

    ci框架默认的url规则中带有应用的入口文件,例如: example.com/index.php/news/article/my_article 在以上URL中带有入口文件index.PHP,这样的U ...

  6. [Codeforces626F] Group Projects (DP)

    Group Projects Description There are n students in a class working on group projects. The students w ...

  7. SqlSever基础 intersect 交集 两个查询结果共有的

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  8. 定义一个“点”(Point)类用来表示三维空间中的点(有三个坐标)。要求如下: (1)可以生成具有特定坐标的点对象。 (2)提供可以设置三个坐标的方法。 (3)提供可以计算该“点”距原点距离平方的方法。 (4)编写主类程序验证。

    package b; public interface ZuoBiao { double zuobiao(); } package b; public class Point implements Z ...

  9. 专题:php页面跳转方法

    php只有一种方法,利用JavaScript的window.location[和window.location.href效果相同]是一种方法,利用html的meta的Refresh是一种方法. 代码 ...

  10. 【转】ffmpeg参数中文详细解释

    感谢“大神”的无私奉献:http://blog.csdn.net/leixiaohua1020/article/details/15811977 a) 通用选项 -L license-h 帮助-fro ...