poj 2406 Power Strings

【POJ2406】Power Strings 中文题意&题解&代码(C++) kmp求循环节,nex数组的性质 阅读详情

链接:poj 2406

题意:求给定字符串最大循环次数

思路:根据KMP算法的next数组知,一个长度为n的字符串,

if(n%(n-next[n])==0)

最小循环长度为  L=n-next[n];

最大循环次数为  S=n/L=n/(n-next[n]);

#include<stdio.h>
#include<string.h>
int next[1001010]={-1},n;
char s[1001010];
int getnext()
{
    int i=0,j=-1;
    while(i<n){
        if(j==-1||s[i]==s[j]){
            i++;
            j++;
            next[i]=j;
        }
        else
            j=next[j];
    }
    if(n%(n-next[n])==0)
        return n/(n-next[n]);
    return 1;
}
int main()
{
    while(scanf("%s",s)!=EOF){
        if(strcmp(s,".")==0)
            break;
        n=strlen(s);
        n=getnext();
        printf("%d\n",n);
    }
    return 0;
}


【传感器标定(三):激光雷达标定原理与实现详解】 本文系统介绍了激光雷达标定的基本原理与方法。主要内容包括:激光雷达标定的分类(内参标定和外参标定)、坐标系定义和刚体变换数学基础;详细阐述了测距误差和光束方向两种内参标定方法;重点分析了基于目标(平面标定板、三维标定物)和基于运动(手眼标定、点云配准)的外参标定方法;介绍了多传感器联合标定技术及非线性优化、鲁棒标定等实现方法;最后提出了定量和定性两种标定评估体系。为激光雷达在自动驾驶等领域的精确应用提供了系统的标定技术指导。 阅读详情

相关推荐

C# 开发 WPS 插件实战:从环境搭建到功能实现(附完整代码)

本文提供了一份详尽的C#开发WPS插件实战指南,涵盖从环境搭建到功能实现的完整流程。通过COM技术,开发者可以创建自定义插件,为WPS Office扩展自动化功能,如文档处理与格式转换。文章包含核心概念解析、Ribbon界面集成、调试部署方法及完整代码示例,帮助开发者快速上手。

rust6ferris的博客 926

【POJ 2406】 Power Strings

【题目链接】           点击打开链接【算法】         KMP         如果字符串中存在循环节,则next[len] = (循环节个数 - 1) * 循环节长度                                                     循环节个数 = len / (len - next[len]) 【代码】           #include...

even_bao的博客 295

【Cadence】PSS+PSTB/PAC仿真在开关电源稳定性分析中的关键应用

本文深入探讨了Cadence仿真工具中PSS+PSTB/PAC方法在开关电源稳定性分析中的关键应用。针对开关电源作为时变非线性系统的特性,传统STB仿真方法会失效。文章详细阐述了如何通过PSS分析找到周期稳态,并在此基础上利用PSTB或PAC进行精确的环路增益和小信号频响分析,为电源设计提供可靠的稳定性评估与补偿网络设计依据。

weixin_29276847的博客 522

Poj 2406 Power Strings

http://www.studyai.com/article/114bf471

Mercury的博客 482

从零开始用STM32驱动RGB屏:配置PCLK、DE同步信号的避坑指南

本文详细介绍了如何使用STM32驱动RGB接口LCD屏幕,重点解析了PCLK配置、同步信号极性和DE使能等关键参数的设置方法。通过实战代码示例和常见问题排查指南,帮助开发者避免常见配置错误,实现稳定的显示效果。特别针对800x480 IPS屏提供了优化建议和调试技巧。

sky77的博客 539

将CityScapes数据集转换为COCO格式的实例分割数据集

##¥##2019年结束前最后两小时,写出本年度最后一篇博客,不是博主没地方去跨年,实在是Coding乐趣无穷ahhhh ##¥## COCO数据集是研究实例分割的通用数据集,但是针对道路环境的数据较少,对于自动驾驶和移动机器人的应用并不适配。而提供道路环境的实例分割数据的数据集目前有KITTI、CityScapes、Apllo等,CityScapes算是应用较广,数据质量较高的一个,所以,本篇...

陆羽飞的博客 9940

POJ 2406 Power Strings

Power Strings Time Limit: 1000MS Memory limit: 65536K 题目描述 Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abc

叶孤心的专栏 765

RAG测评实战代码

本文主要介绍了RAG测评实战代码,希望对使用RAG的同学们有所帮助。 文章目录 1. 前言 2. 实战代码 2.1 实战代码一 2.2 实战代码二

herosunly的博客 1万+

POJ-2406 Power Strings

POJ-2406 Power Strings 题目链接:POJ-2406 题目大意:检测一个字符串从头开始最多有多少个重复片段 解题思路:利用kmp的求next数组的方法 求出next数组,之后看前缀和后缀最长的重合有多长 总长度减去重合的长度就是一个一个重复片段的长度 最后总长度除以一个重复片段的长度即可得出结果,当然如果总长度不是得出的重复片段长度的整数倍,说明只有最前面字符自己喽,输出一就...

鱼头的水题之路 277

第一节:Vben Admin 最新 v5.0 (vben5) + Python Flask 快速入门

vben5 快速入门。 Vben Admin 框架新出的版本V5.5.4,而之前的Vben Admin 2.x 目前已存档,仅进行重大问题修复。之前在2.x版本曾经简单完成了一版专栏文章,当时也是收获了一些好评和建议。本次决定在v5 版本基础上再完成一次前后端的搭建。希望大家继续多多支持。项目精简后,再次启动项目,执行 pnpm run dev点击登录,可以看到接口报错,现在前端请求的后端有报错,下一节处理这部分逻辑。

cuiwin的专栏 7061

TIBCO Jaspersoft Studio报表开发 使用教程-进阶版

本文学习内容容器定制二级目录三级目录 容器定制 二级目录 三级目录

吉哲的博客 7519

POJ - 2406 Power Strings

后缀数组DC3算法模板题,加了一个Debug()函数,依旧是模板题

The Blog Of Uncle_Sugar 339

东北大学计算机预推免(双非友好)

东北大学,个人觉得在985里面对双非比较友好,而且学校的计算机专业实力也比较强,上岸难度不算很大,可以重点关注一下。学校复试审核的时间比较早,拿到复试资格之后,一定要留意报名系统首页中计算机学院的信息,学校也会在全国各地不同时间安排面试,可以根据自己的情况选择一个合适的时间前去面试,并且有对应面试场次的QQ群,信息会在群里面发布。面试成绩会在预推免系统中直接公布,但是是否拟录取不会公布,需要考生自行判断,今年计算机学院录取线定在了86分左右,最终递补下来,好像录取到了84分左右。

D1379951481的博客 3120

POJ 2406 Power Strings(后缀数组做法超时)

POJ 2406 Power Strings(后缀数组) http://poj.org/problem?id=2406 题意:一个串确定是由一个或多个循环节构成的,现在要你求出这个串由最多几个循环节构成的.(即用串长除以最短循环节的长度). 分析:本题可以用KMP算法求解,简单方便代码段只有30行,O(n)复杂度: http://blog.youkuaiyun.com/u013480600/artic

code 1393

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

KMP-(POJ 2406)Power Strings[字符串乘方]

KMP-(POJ 2406)Power Strings[字符串乘方] 题目链接:Power Strings 思路:最小循环节 看到乘方,很明显是求给定字符串由它的最小循环子串循环得到的次数 那就是求出NEXT数组,再而求出最小循环节长度:Len-NEXT[Len] 有三种情况,分两类 ①给定字符串循环子串是其本身:乘方等于1         a.NEXT[Len]...

[SZU_Crayon] 728

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

POJ2406 Power Strings(Hash)

传送门 分析 枚举子串的长度,然后判断是否后面的没一段都与子串相等。 用字符串Hash判断是否相等。 代码 #include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define full(a,b) memset(a,b,sizeof a) #define ll long long #define ui u...

灰色的人的博客 373

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Power Strings (POJ-2406)

Power Strings (POJ-2406) Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication...

菜鸡的博客 224

POJ 2406 Power Strings

题目链接:http://poj.org/problem?id=2406 参考:http://blog.youkuaiyun.com/u010489766/article/details/9272489 #include #include int next[1100000]; char str[1100000]; int len; void get_next() { int

u010489766的专栏 1037

POJ2406Power Strings

来源:http://poj.org/problem?id=2406  Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 30293   Accepted: 12631 Description Given two strin

MummyDing's Blog 1065

POJ2406 Power Strings

题目链接:POJ2406 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 41439   Accepted: 17231 Description Given two strings a and b we defi

teddywang 361

【POJ 2406】Power Strings

问题描述 Given two strings a and b we define a*b to be their concatenation. For example, if a = “abc” and b = “def” then a*b = “abcdef”. If we think of concatenation as multiplication, exponentiation by a

Fallen_Angel001的博客 349

POJ 2406 Power Strings

2016暑期集训7-APOJ 2406 Power Stringskmp变形,next数组的应用 传送门:关于kmp算法 传送门:POJ 传送门:HustOJ 题意给一字符串,寻找最小的循环节最多循环多少次才能构成这个字符串。输出次数。 比如‘aaaa’由4个‘a’构成,循环节出现4次;‘abababababab’最短循环节‘ab’出现6次。思路kmp中的next数组作用就是找循环

P.H.S 386
上一篇: poj 1961 Period
下一篇: poj 3126 Prime Path (bfs)
happy_lcj
博客等级 码龄13年 7粉丝 152原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值