链接

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

 #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. JavaEE基础(十二)

    1.常见对象(Scanner的概述和方法介绍) A:Scanner的概述 B:Scanner的构造方法原理 Scanner(InputStream source) System类下有一个静态的字段: ...

  2. js 对象toString()方法

    ({}+{}).length == 30; ({}).toString() '[object Object]' 当对象需要调用toString()方法时会被自动调用.

  3. JavaScript DOM 编程艺术(第2版)读书笔记 (8)

    <!--这章的内容略奇怪啊!可能是因为我之前没有接触过这些知识点,等以后用到的时候再回来翻阅吧,现在先简要介绍一下 js权限已通过,博客园好快的效率啊,谢谢O(∩_∩)O --> 缩略语 ...

  4. android FragmentPagerAdapter getItem方法没有执行

    转自 http://blog.csdn.net/getchance/article/details/40263505 在一个 Android 应用中,我使用 FragmentPagerAdapter  ...

  5. SDUT 2603:Rescue The Princess

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  6. java对象equals方法的重写

    根类Object中的equals方法描述: public boolean equals(Object obj)The equals method for class Object implements ...

  7. 基本的MFC多线程

    多线程程序我本来是能够来写的.但是由于在图像处理的过程中,对于这方面知识使用的比较少,造成重复忘记的情况.这里再次进行整理学习,特别注重和“图像处理”理清关系,为下一步使用奠定基础. 这里实现的是工作 ...

  8. JAVA基础知识之多线程——线程的生命周期(状态)

    线程有五个状态,分别是新建(New).就绪(Runnable).运行(Running).阻塞(Blocked)和死亡(Dead). 新建和就绪 程序使用new会新建一个线程,new出的对象跟普通对象一 ...

  9. vilte/vowifi

    vendor/mediatek/proprietary/packages/services/Ims/src/com/mediatek/ims/ImsService.java ¦ ¦ ¦ ¦ ¦ ¦ v ...

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

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