后缀数组专题的 emm。。

就next 循环节。。/

有后缀数组也可以做

从小到大枚举长度i,如果长度i的子串刚好是重复了len/i次,应该满足len % i == 0和rank[0] - rank[i] == 1(整个串的等级比 i位置开始的后缀的等级大1  (i位置开始的后缀即为比总串低一个等级的后缀)) 和height[rank[0]] == len-i (整个串 和 比它低一个等级的串的最长公共前缀的长度 是总长度减去这个循环节的长度)这些条件的

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = 1e6+, INF = 0x7fffffff;
int nex[maxn]; void get_next(char *s)
{
int len = strlen(s);
int j, k;
j = , k = -, nex[] = -;
while(j < len)
{
if(k == - || s[j] == s[k])
nex[++j] = ++k;
else
k = nex[k];
}
} char s[maxn];
int main()
{
while(~rs(s) && s[] != '.')
{
get_next(s);
int n = strlen(s);
if(n % (n - nex[n]) == )
cout<< n / (n - nex[n]) <<endl;
else
cout<< <<endl; } return ;
}

Power Strings POJ - 2406(next水的一发 || 后缀数组)的更多相关文章

  1. Power Strings POJ - 2406

    Power Strings POJ - 2406 时限: 3000MS   内存: 65536KB   64位IO格式: %I64d & %I64u 提交 状态 已开启划词翻译 问题描述 Gi ...

  2. ( KMP 求循环节的个数)Power Strings -- poj -- 2406

    链接: http://poj.org/problem?id=2406 Power Strings Time Limit:3000MS     Memory Limit:65536KB     64bi ...

  3. Power Strings (poj 2406 KMP)

    Language: Default Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 33205   ...

  4. Power Strings POJ - 2406 后缀数组

    Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc&quo ...

  5. Match:Power Strings(POJ 2406)

     字符串前缀的阶 题目大意:求前缀的阶 和POJ1961是一样的,KMP的Next数组的应用,不要用STL,不要一个一个读入字符(IO永远是最慢的) #include <iostream> ...

  6. Power Strings - POJ 2406(求循环节)

    题目大意:叙述的比较高大上,其实就是一个字符串B = AAAAAAA,求出来这个A最短有多长   分析:注意如果这个串不是完全循环的,那么循环节就是就是它本身.   代码如下: #include< ...

  7. poj 2774 最长公共子串 后缀数组

    Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 25752   Accepted: 10 ...

  8. [POJ 2774] Long Long Message 【后缀数组】

    题目链接:POJ - 2774 题目分析 题目要求求出两个字符串的最长公共子串,使用后缀数组求解会十分容易. 将两个字符串用特殊字符隔开再连接到一起,求出后缀数组. 可以看出,最长公共子串就是两个字符 ...

  9. POJ 2774 Long Long Message(后缀数组)

    [题目链接] http://poj.org/problem?id=2774 [题目大意] 求最长公共子串 [题解] 将两个串中间嵌一个字符相连,求一遍后缀数组 如果排名相邻的两个后缀的开端是分属于两个 ...

随机推荐

  1. stl源码分析之hash table

    本文主要分析g++ stl中哈希表的实现方法.stl中,除了以红黑树为底层存储结构的map和set,还有用哈希表实现的hash_map和hash_set.map和set的查询时间是对数级的,而hash ...

  2. java IO流 对文件操作的代码集合

    Io流 按照分类 有两种分类 流向方向: 有输入流和输出流 按照操作类型有:字节流和字符流 按照流向方向 字节流的一些操作 //读文件 FileInputStream fis = new FileIn ...

  3. gulp: Did you forget to signal async completion? 解决方案

    背景 学习gulp的前端自动化构建,按照示例代码,跑了一个简单的task,控制台打出如下提示: The following tasks did not complete: testGulp Did y ...

  4. 跨域Ajax -- jsonp和cors

    跨域Ajax - jsonp - cors 参考博客: http://www.cnblogs.com/wupeiqi/articles/5703697.html http://www.cnblogs. ...

  5. crosstool-ng搭建交叉编译环境注意事项

    一,crosstool-ng的下载及编译方法 可以参考如下网站: http://www.crosstool-ng.org/ 二,编译过程注意事项 1)如果遇到有些代码包不能下载,请依据指定版本,在这里 ...

  6. 随手记录-linux-Shellinabox插件

    Shellinabox 是一个利用 Ajax 技术构建的基于 Web 的远程Terminal 模拟器,也就是说安装了该软件之后,不需要开启 ssh服务,通过 Web 网页就可以对远程主机进行维护操作了 ...

  7. PHP使用Memcache来存储session 其他【转载】

    PHP使用Memcache来存储session 分类:PHP 时间:2015年3月30日 很多时候一个完整的系统可能运行在多个服务器上,如果这多个服务器之间需要共享session的话,那么PHP默认的 ...

  8. Node.js中module文件定义的top-level变量为何是私有的

    在Node.js中,module文件里面使用var,const或者let定义的top-level变量为何是私有的,只能在这个模块文件中使用呢? 原因就是,在模块文件中的内容执行之前,node.js会降 ...

  9. BugPhobia开发篇章:Alaph阶段Scurm Meeting

    [github]   https://github.com/bugphobia/XuebaOnline 0x01 :目录与摘要 If you weeped for the missing sunset ...

  10. 20162328蔡文琛 2017week03

    20162328 2017-2018-1 <程序设计与数据结构>第3周学习总结 教材学习内容总结 查找是在一组项内找到指定目标或是确定目标不存在的过程. 搞笑的查找使得比较的次数最少. C ...