poj1244Slots of Fun
几何的简单题,建立坐标,判断相等以及不共线
#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的更多相关文章
随机推荐
- Symfony电子商务
http://zhilihe.com/content/symfony%E7%94%B5%E5%AD%90%E5%95%86%E5%8A%A1%E9%A1%B9%E7%9B%AE%E6%80%BB%E7 ...
- c# 回调委托
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- hdu1074 Doing Homework
这题比较有意思,暴力搜索必然tle,可以用状态压缩dp解决. 我们先不考虑完成所有作业的扣分,而考虑其一个子集的情况. 假设我们得到了完成某子集S对应的作业最少扣分,我们试着向该子集中增加一个元素a, ...
- JAVA基础知识之多线程——线程组和未处理异常
线程组 Java中的ThreadGroup类表示线程组,在创建新线程时,可以通过构造函数Thread(group...)来指定线程组. 线程组具有以下特征 如果没有显式指定线程组,则新线程属于默认线程 ...
- linux学习建议
给初学者的建议 注意事项: 1 严格区分大小写,包括命令和文件夹,windows和linux的系统不太一样 2 所有内容都是以文件保存,包括硬件,文件要永久生效,都要写入文件,所以文件命令很重要 3 ...
- 2016 ACM/ICPC Asia Regional Qingdao Online HDU5883
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5883 解法:先判断是不是欧拉路,然后枚举 #pragma comment(linker, "/S ...
- Android内存Context泄露:Handler&内部类
1 public class SampleActivity extends Activity { 2 3 private final Handler mLeakyHandler = new Handl ...
- java5、java6、java7、java8的新特性
Java5: 1.泛型 Generics: 引用泛型之后,允许指定集合里元素的类型,免去了强制类型转换,并且能在编译时刻进行类型检查的好处. Parameterized Type作为参数 ...
- iis 500 解决方法
1 打开运行,输入cmd进入到命令提示符窗口. 2 进入到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 目录. 3 输入aspnet_regiis.exe ...
- ContentProvider官方教程(1)何时用content provider
Content Providers Content providers manage access to a structured set of data. They encapsulate the ...