Power Strings - POJ 2406(求循环节)
- #include<stdio.h>
- #include<string.h>
- const int MAXN = 1e6+;
- const int oo = 1e9+;
- char s[MAXN];
- int next[MAXN];
- void GetNext(int N)
- {
- int i=, j=-;
- next[] = -;
- while(i < N)
- {
- if(j==- || s[i]==s[j])
- next[++i] = ++j;
- else
- j = next[j];
- }
- }
- int main()
- {
- while(scanf("%s", s), strcmp(s, "."))
- {
- int N = strlen(s);
- GetNext(N);
- int circle = N - next[N];
- if(N % circle == )
- printf("%d\n", N/circle);
- else
- printf("1\n");
- }
- return ;
- }
Power Strings - POJ 2406(求循环节)的更多相关文章
- Power Strings POJ - 2406
Power Strings POJ - 2406 时限: 3000MS 内存: 65536KB 64位IO格式: %I64d & %I64u 提交 状态 已开启划词翻译 问题描述 Gi ...
- ( KMP 求循环节的个数)Power Strings -- poj -- 2406
链接: http://poj.org/problem?id=2406 Power Strings Time Limit:3000MS Memory Limit:65536KB 64bi ...
- poj 2406 Power Strings【字符串+最小循环节的个数】
Po ...
- Power Strings (poj 2406 KMP)
Language: Default Power Strings Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 33205 ...
- Power Strings POJ - 2406 后缀数组
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc&quo ...
- Power Strings POJ - 2406(next水的一发 || 后缀数组)
后缀数组专题的 emm.. 就next 循环节../ 有后缀数组也可以做 从小到大枚举长度i,如果长度i的子串刚好是重复了len/i次,应该满足len % i == 0和rank[0] - rank[ ...
- Match:Power Strings(POJ 2406)
字符串前缀的阶 题目大意:求前缀的阶 和POJ1961是一样的,KMP的Next数组的应用,不要用STL,不要一个一个读入字符(IO永远是最慢的) #include <iostream> ...
- HDU 3746 Cyclic Nacklace (KMP求循环节问题)
<题目链接> 题目大意: 给你一个字符串,要求将字符串的全部字符最少循环2次需要添加的字符数. [>>>kmp next函数 kmp的周期问题] #include &l ...
- Java求循环节长度
两个整数做除法,有时会产生循环小数,其循环部分称为:循环节.比如,11/13=6=>0.846153846153..... 其循环节为[846153] 共有6位.下面的方法,可以求出循环节的长 ...
随机推荐
- 使用OC开发phonegp 组件
使用OC开发phonegp 组件 1. 使用oc 对phonegp中的组件近些开发,首先具体的pgonegp跟nativecode之间的一些优劣就不说了,开发phonegp 对应的组件主要就是使用na ...
- javascript基础学习(三)
javascript之运算符 学习要点: 表达式 运算符:一元运算符,算术运算符,关系运算符,逻辑运算符,*位运算符,赋值运算符 一.表达式 表达式有常量表达式,变量表达式,复合表达式. 二.算术运算 ...
- OpenCV中Mat的详解
每次碰到Mat都得反复查具体的用法,网上的基础讲解不多,难得看到一篇,赶快转来收藏~ 原文地址:http://www.opencvchina.com/thread-1039-1-1.html 目标 我 ...
- POJ刷题记录 (。・`ω´・)(Progress:6/50)
1743:前后作差可以转化成不可重叠最长公共字串问题,运用后缀数组解决(参考罗穗骞神犇的论文) #include <cstdio> #include <cstring> #in ...
- login-登录
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Inse ...
- javascript实现ajax
什么是 ajax ajax 即“Asynchronous JavaScript and XML”(异步 JavaScript 和 XML),也就是无刷新数据读取. http 请求 首先需要了解 htt ...
- 面试小结(java基础)
一个.java源文件中可以有多个类吗?(内部类除外)有什么条件?带着这个疑惑,动手建几个测试类, 揭开心中的疑惑.以下是解开疑惑过程: package test;/** * 一个.java源文件中可以 ...
- Android 即时语音聊天工具 开发
使用融云SDK 1. 功能需求分析 1.1 核心功能需求: * 即时通讯 * 文字聊天 * 语音聊天 1.2 辅助功能需求: * 注册.登录 * 好友添加功能 * 好友关系管理 2. 融云即时通讯平台 ...
- python之json
import json import requests re = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=成都') re.en ...
- python cx_Oracle install
Ubuntu install python-cx_Oracle 1: install alien tools . sudo apt-get install alien 2: dowload fol ...