链接

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

 #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. return break continue

    return 程序返回,不再执行下面的代码(结束当前的方法 直接返回) break 跳出总上一层循环,不再执行循环(结束当前的循环体)continue 跳出本次循环,继续执行下次循环(结束正在执行的循 ...

  2. 在ecshop顶部会员信息提示区显示会员等级

    会员登陆后,在顶部会员信息提示区显示会员等级会员登陆后会在顶部出现这样的提示:您好,test2, 欢迎您回来 ! 进入用户中心 |退出现在设想在会员名后面加上“会员等级”效果如下:您好,test2,  ...

  3. Android处理图片OOM的若干方法小结 (推荐)

    众所周知,每个Android应用程序在运行时都有一定的内存限制,限制大小一般为16MB或24MB(视平台而定).因此在开发应用时需要特别关注自身的内存使用量,而一般最耗内存量的资源,一般是图片.音频文 ...

  4. [团队项目]----Math Calculator

    团队项目 ----Math Calculator 任务: 1.每个团队从Github上fork这个项目的源代码 https://github.com/RABITBABY/We-have-bing 2. ...

  5. 山东理工大学第七届ACM校赛-LCM的个数 分类: 比赛 2015-06-26 10:37 18人阅读 评论(0) 收藏

    LCM的个数 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 对于我们来说求两个数的LCM(最小公倍数)是很容易的事,现在我遇到了 ...

  6. 使用自定义材质球,实现NGUI屏幕溶解和灰显

    UITexture实现的溶解: 重设UITeture的材质球实现上述效果,把当前屏幕渲染的Texture2D丢给UITexture,即可实现UI屏幕特效,背景模糊等都可以. 难点主要是实时刷新问题 解 ...

  7. shell脚本常见错误

    一.引言 想要学习使用shell脚本,却在开始的时候遇到很多不顺利,都是一些小细节的东西,所以在此记录一下. 二.各种细节问题 1.变量作为赋值对象时不需要添加$,取值时需要,也就是说,这个$就是取值 ...

  8. 《redis-php中文参考手册》

    <redis中文手册>,将示例代码用php来实现,注意php-redis与redis_cli的区别(主要是返回值类型和参数用法). phpredis是redis的php的一个扩展,效率是相 ...

  9. Struts2的配置

    Struts2的配置 Struts2可以通过Convention插件管理Action和结果映射,也可以通过使用XML文件进行管理,这两种方式各有好处:使用Convention插件管理减少了XML文件的 ...

  10. Lucky String

    Lucky String -- 微软笔试 标签(空格分隔): 算法 A string s is LUCKY if and only if the number of different charact ...