POJ 1244 Slots of Fun(计算几何)

时间:2023-03-09 17:27:25
POJ 1244 Slots of Fun(计算几何)

题目链接

很简单的一题,数据 很小,直接暴力的。但是也是写也好久,有几个数,没算好。。。一次CE,一次PE,3Y。

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define eps 1e-8
#define zero(x) (((x) > 0?(x):-(x))<eps)
int o[];
struct point
{
double x,y;
} p[];
double dis(point p1,point p2)
{
return (p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y);
}
int judge(int i,int j,int k)
{
if(zero(dis(p[i],p[j])-dis(p[j],p[k]))&&zero(dis(p[i],p[j])-dis(p[i],p[k])))
return ;
else
return ;
}
char str[];
int main()
{
int n,i,j,k,num = ,len,flag;
double d;
p[].x = ;
p[].y = ;
for(i = ; i <= ; i ++)
{
d = (i-)*1.0*sqrt(3.0)*2.0/3.0/(i-);
p[num].x = -(i-)*1.0*sqrt(3.0)/3.0;
p[num].y = i-;
num ++;
for(j = ; j < i; j ++)
{
p[num].x = p[num-].x + d;
p[num].y = i-;
num ++;
}
}
while(scanf("%d",&n)!=EOF)
{
if(n == ) break;
memset(o,,sizeof(o));
scanf("%s",str);
len = strlen(str);
flag = ;
for(i = ; i < len; i ++)
{
for(j = i+; j < len; j ++)
{
if(str[i] == str[j])
for(k = j+; k < len; k ++)
{
if(str[j] == str[k])
{
if(judge(i,j,k))
{
flag = ;
o[str[i]+] ++;
}
}
}
}
}
if(!flag)
{
printf("LOOOOOOOOSER!\n");
continue;
}
for(i = ;i <= ;i ++)
{
if(o[i])
{
for(j = ;j <= o[i];j ++)
printf("%c",i);
}
}
printf("\n");
}
return ;
}