题目链接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1504

题意

给出一串字符串 里面的每个字符的位置 都按照题目的意思 给出

求哪些字母 所在的位置 随意三个点 是否能构成 一个 正三角形 如果能 就输出这个字母 最后输出的结果 要按照字典序

思路

难点在于 给这些字母赋予坐标

我们可以从最底层 来赋值

最底层的 Y坐标都是1 X坐标分别是 `1, 2, 3, 4

然后往上走 的坐标 都是右 下一层的两个坐标决定的

X的坐标 是 下一层两个坐标的终点 Y坐标是下面一层坐标Y坐标+ sqrt(3)/2

数据范围很小 用 O(n^3) 暴力 都是可以过的

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits> #define CLR(a, b) memset(a, (b), sizeof(a))
#define pb push_back using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair<string, int> psi;
typedef pair<string, string> pss; const double PI = acos(-1.0);
const double E = exp(1.0);
const double eps = 1e-8; const int INF = 0x3f3f3f3f;
const int maxn = 4e5 + 5;
const int MOD = 1e9 + 7; struct node
{
double x, y;
int c;
}q[12][12]; double dis(node a, node b)
{
double ans = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
return ans;
} bool EPS(double x, double y)
{
if (fabs(x - y) < eps)
return true;
return false;
} bool equil(node a, node b, node c)
{
double Dis1 = dis(a, b);
double Dis2 = dis(a, c);
double Dis3 = dis(b, c);
if (EPS(Dis1, Dis2) && EPS(Dis1 , Dis3) && EPS(Dis2, Dis3))
return true;
return false;
} int main()
{
int n;
while (scanf("%d", &n) && n)
{
string s;
cin >> s;
int len = s.size();
vector <node> c[26];
CLR(q, 0);
for (int i = 0, count = 0; i < n; i++)
{
for (int j = 0; j < i + 1; j++)
{
q[i][j].c = s[count++] - 'a';
}
}
for (int i = 0; i < n; i++)
{
q[n - 1][i].x = i + 1;
q[n - 1][i].y = 1;
c[q[n - 1][i].c].pb(q[n - 1][i]);
}
for (int i = n - 2; i >= 0; i--)
{
for (int j = 0; j <= i; j++)
{
q[i][j].y = q[i + 1][j].y + sqrt(3.0) * 1.0 / 2;
q[i][j].x = (q[i + 1][j].x + q[i + 1][j + 1].x) * 1.0 / 2;
c[q[i][j].c].pb(q[i][j]);
}
}
string ans = "";
for (int l = 0; l < 26; l++)
{
int len = c[l].size();
int flag = 0;
for (int i = 0; i < len; i++)
{
for (int j = 0; j < len; j++)
{
for (int k = 0; k < len; k++)
{
if (i != j && i != k && j != k && flag == 0)
{
if (equil(c[l][i], c[l][j], c[l][k]))
{
ans += l + 'a';
flag = 1;
}
}
}
}
}
}
if (ans == "")
printf("LOOOOOOOOSER!\n");
else
cout << ans << endl;
}
}

ZOJ - 1504 Slots of Fun 【数学】的更多相关文章

  1. zoj 1028 Flip and Shift(数学)

    Flip and Shift Time Limit: 2 Seconds      Memory Limit: 65536 KB This puzzle consists of a random se ...

  2. ZOJ 2679 Old Bill(数学)

    主题链接:problemCode=2679" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProbl ...

  3. ZOJ 2680 Clock()数学

    主题链接:problemId=1680" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProblem ...

  4. zoj 2722 Head-to-Head Match(数学思维)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2722 题目描述: Our school is planning ...

  5. ZOJ 3203 Light Bulb(数学对勾函数)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  6. ZOJ - 3866 Cylinder Candy 【数学】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3866 思路 积分 参考博客 https://blog.csdn. ...

  7. ZOJ - 3993 - Safest Buildings (数学)

    参考:https://blog.csdn.net/KuHuaiShuXia/article/details/78408194 题意: 描述了吃鸡刷圈的问题,给出楼的坐标点,和两次刷圈的半径R和r,现在 ...

  8. ZOJ 3819 Average Score(数学 牡丹江游戏网站)

    主题链接:problemId=5373">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Bob is ...

  9. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

随机推荐

  1. dedecms 调用父栏目下的所有子栏目

    效果如下: 代码如下: <div class="productxilie"> <ul> {dede:channelartlist row=6 typeid ...

  2. 【共享单车】—— React后台管理系统开发手记:Router 4.0路由实战演练

    前言:以下内容基于React全家桶+AntD实战课程的学习实践过程记录.最终成果github地址:https://github.com/66Web/react-antd-manager,欢迎star. ...

  3. Redis 架构设计

    1.设计层面 (1) 存储小而热的数据 (2) 结合业务数据特点,正确使用内存类型 (3) 冷.热数据分离 2.架构层面 (1) 提前做好容量(内存)规划 (2) 结合持久化模式优劣正确使用,一般建议 ...

  4. uboot下netconsole的原理及用法

    近期发现uboot下一个非常有意思也非常有用的功能:netconsole,uboot下的netconsole相似于kernel下的telnet等网络终端功能,将网络作为输入输出的终端,这样就便于我们在 ...

  5. centos 7 mariadb 安装

    yum install -y mariadb mariadb-server systemctl start mariadb systemctl enable mariadb #初始化 mysql_se ...

  6. vue2.X 自定义 侧滑菜单 组件

    1.vue2.0 封装 侧滑菜单组件 Sidebar.vue <!-- 侧滑菜单 组件 --> <template> <div> <transition na ...

  7. 33:字符统计SumOfCharactors

    题目描述:如果统计的个数相同,则按照ASII码由小到大排序输出 .如果有其他字符,则对这些字符不用进行统计. 实现以下接口: 输入一个字符串,对字符中的各个英文字符,数字,空格进行统计(可反复调用) ...

  8. VTK学习之路——画画我的小苹果

    数据集主要由描写叙述数据集几何形状的点集数据及构成数据集的单元构成,因此构建数据集的主要任务就是确定点集和构建单元,本演示样例程序构建了一个苹果的实体,然后绘制苹果.演示样例程序运行的过程例如以下: ...

  9. LeetCode 之 Valid Palindrome(字符串)

    [问题描写叙述] Given a string, determine if it is a palindrome, considering only alphanumeric characters a ...

  10. JavaScript框架——jquery

    1.jQuery编程常识   ————————如何进行jQuery插件开发   2.五星评分——jQuery Raty 一个很棒的jQuery评分插件—jQuery Raty         3.能感 ...