poj2752-Seek the Name, Seek the Fame
来源:互联网 发布:嵌入式开发和单片机 编辑:程序博客网 时间:2024/06/04 19:37
//要充分了解next数组所代表的含义
#include<iostream>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<cstlib>#include<map>#include<queue>#include <deque>#include <list>#include <ctime>#include <stack>#include <vector>#include<set>#define Maxn 400100typedef long long ll;#define FOR(i,j,n) for(int i=j;i<=n;i++)#define DFR(i,j,k) for(int i=j;i>=k;--i)#define lowbit(a) a&-a#define Max(a,b) a>b?a:b#define Min(a,b) a>b?b:aconst int inf = 0x3f3f3f3f;const double pi = acos(-1.0);using namespace std;int next[Maxn],len1,book[Maxn];char p[Maxn];void getNext(){ next[0] = -1; int i = 0; int j = -1; while (i < len1) { if (j == -1 || p[i] == p[j]) next[++i] = ++j; else j = next[j]; }}int main(){ while(~scanf("%s",p)) { len1=strlen(p); getNext(); int cnt=0; for(int i=len1;next[i]!=-1;i=next[i]) book[cnt++]=i; <span style="white-space:pre"></span>DFR(i,cnt-1,0) printf("%d%c",book[i],i==0?'\n':' '); } return 0;}
0 0
- POJ2752 Seek the Name, Seek the Fame
- POJ2752:Seek the Name, Seek the Fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 seek the name seek the fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752-Seek the Name, Seek the Fame
- poj2752 Seek the Name,Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 seek the name,seek the fame
- POJ2752 Seek the Name, Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- poj2752 Seek the Name, Seek the Fame
- POJ2752-Seek the Name, Seek the Fame
- [POJ2752] Seek the Name,Seek the Fame
- POJ2752 Seek the Name, Seek the Fame
- 【POJ2752】seek the name,seek the fame
- python-->django使用过程中碰到的异常总结
- Nginx基础篇之一—Nginx在Ubuntu的安装
- poj-3349Snowflake Snow Snowflakes
- Aizu - 2306 Rabbit Party (DFS图论)
- Scramble String
- poj2752-Seek the Name, Seek the Fame
- 内联函数详解--C++
- 欢迎使用CSDN-markdown编辑器
- 协处理器
- 使用context.RewritePath来实现伪静态
- 使用HTTP协议从网上获取资源下载到本地(1)
- HDOJ1274展开字符串
- 具体情境决定一切
- 找出二进制表示中1的个数相同,且大小最接近的那两个数