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 ;
}
POJ 1244 Slots of Fun(计算几何)的更多相关文章
- 2018.07.04 POJ 1654 Area(简单计算几何)
Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...
- POJ 2826 An Easy Problem?! --计算几何,叉积
题意: 在墙上钉两块木板,问能装多少水.即两条线段所夹的中间开口向上的面积(到短板的水平线截止) 解法: 如图: 先看是否相交,不相交肯定不行,然后就要求出P与A,B / C,D中谁形成的向量是指向上 ...
- POJ 1066 Treasure Hunt(计算几何)
题意:给出一个100*100的正方形区域,通过若干连接区域边界的线段将正方形区域分割为多个不规则多边形小区域,然后给出宝藏位置,要求从区域外部开辟到宝藏所在位置的一条路径,使得开辟路径所需要打通的墙壁 ...
- POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)
Toy Storage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3146 Accepted: 1798 Descr ...
- 2018.07.04 POJ 3304 Segments(简单计算几何)
Segments Time Limit: 1000MS Memory Limit: 65536K Description Given n segments in the two dimensional ...
- poj 1696:Space Ant(计算几何,凸包变种,极角排序)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2876 Accepted: 1839 Descrip ...
- poj 2187:Beauty Contest(计算几何,求凸包,最远点对)
Beauty Contest Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 26180 Accepted: 8081 D ...
- POJ 1127 Jack Straws (计算几何)
[题目链接] http://poj.org/problem?id=1127 [题目大意] 在二维平面中,给出一些木棍的左右端点,当木棍相交或者间接相交时 我们判断其连通,给出一些询问,问某两个木棍是否 ...
- poj 1127 -- Jack Straws(计算几何判断两线段相交 + 并查集)
Jack Straws In the game of Jack Straws, a number of plastic or wooden "straws" are dumped ...
随机推荐
- ASP.NET Web API 控制请求频率
参考地址:http://www.cnblogs.com/shanyou/p/3194802.html 安装nuget包:WebApiContrib 很多的api,例如GitHub’s API 都有流量 ...
- phpcms_v9 多图字段 内容页,首页,分页自定义字段调用
phpcms_v9 多图字段 内容页,首页,分页自定义字段调用 说明:自定义多图字段名 shigongtu 1 内容页调用 {loop $shigongtu $r} <img src= ...
- Codeforces Round #333 (Div. 1) D. Acyclic Organic Compounds trie树合并
D. Acyclic Organic Compounds You are given a tree T with n vertices (numbered 1 through n) and a l ...
- POJ 1840 Eqs 二分+map/hash
Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The co ...
- Google自己的下拉刷新组件SwipeRefreshLayout
SwipeRefreshLayout SwipeRefreshLayout字面意思就是下拉刷新的布局,继承自ViewGroup,在support v4兼容包下,但必须把你的support librar ...
- Linux学习笔记(22) Linux启动管理
1. 系统运行级别 运行级别 含义 关机 1 单用户模式,可想象为windows的安全模式,主要用于系统修复 2 不完全的命令行模式,不含NFS服务 完全的命令行模式,就是标准字符界面 4 系统保留 ...
- Maven 项目导入错误解决。
Description Resource Path Location Type Failure to transfer org.apache.maven:maven-core:jar:2.0.6 fr ...
- Java常用命令
jps 查看java进程的PID java -XX:+PrintFlagsInitial 显示所有可设置参数及默认值 java -XX:+PrintFlagsFinal 获取到所有可 ...
- 51nod 1051 求最大子矩阵和
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1051 1051 最大子矩阵和 基准时间限制:2 秒 空间限制: ...
- [工作中的设计模式]单例模式singleton
一.模式解析: 单例模式是最简单和最常用的设计模式,面试的时候,不管新毕业的学生还是已经工作多年的筒子,对单例模式基本都能聊上两句.单例模式主要体现在如下方面: 1.类的构造函数私有化,保证外部不能直 ...