poj1961 period KMP求循环节

linux内核学习(八)---摄像头框架移植(上) 本章来开始进行摄像头的移植,同时回顾一下V4L2的整个框架 阅读详情

http://poj.org/problem?id=1961

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int len,t;
char s[1000005];
int next[1000005];

int main(){
    while(1){
        scanf("%d",&len);
        if(len == 0)break;
        scanf("%s",s);

        printf("Test case #%d\n",++t);

        int i = 0,j = -1;
        next[0] = -1;
        while(i != len){
            if(j == -1 || s[i] == s[j]){
                next[++i] = ++j;
                if(i % (i - next[i]) == 0){
                    int k = i / (i - next[i]);
                    if(k>1)printf("%d %d\n",i,k);
                }
            }
            else j = next[j];
        }
        printf("\n");
    } 

    return 0;
}
chembl_webresource_client 包数据接口下载chembl数据库;ZINC数据库下载、simles获取 点击进去https://zinc.docking.org/subclasses/kinase/predictions/,然后下载sdf模式,这里可以转化simles格式,如果下载csv里面没有包含simles。参考:https://github.com/chembl/chembl_webresource_client/blob/master/demo_wrc.ipynb。参考:https://zinc.docking.org/这是网页搜索查看,16条数据。这个数据这下载特别慢。 阅读详情

相关推荐

组态王|以一定的时间间隔查询某个时间段内的历史数据

使用该函数其他都可以满足,唯一问题是变量的选择,当切换站点后查询历史数据时,所选的变量依然是上次站点查询时所选择的变量,每当更换站点查询时都需要重新选择变量,这一点太繁琐,是用户和操作者无法忍受的。但是由于现场可能数据变化并非太过频繁,想要实现记录频率不变,还是以1分钟一次的频率进行存储,但是报表查询的时候想要只显示整点的数据。其中日历控件的设置与之前的历史数据查询是一样的,报表的抬头设置都是不用变的,此处不再赘述,有兴趣的可以。以上为组态王中以一定的时间间隔查询某个时间段内的历史数据的实现过程。

做有价值的事,积累有价值的笔记! 2544

输出1/n(是循环小数的,只输出第一个循环节)

Input 第一行整数T,表示测试组数。后面T行,每行一个整数 n (1&lt;=|n|&lt;=10^5). Output 输出1/n. (是循环小数的,只输出第一个循环节). Sample Input 4 2 3 7 168 Sample Output 0.5 0.3 0.142857 0.005952380 #include &lt;stdio.h&gt; #include &lt;stdl...

无限迭代中...... 2452

eMMC数据擦除的方式

接下来主要是讲解erase、trim、discard的差异,涉及的command有CMD35、CMD36、CMD38。一般用来擦除整卡或者某些分区,如果只想擦除一个。以下是device status的部分解释。eMMC的数据擦除方式有6种,分别是。将会跳过写保护,只执行其他的范围。Discard的命令序列是。Erase的命令序列是。的范围有包含写保护,Trim的命令序列是。

DPJimmy的博客 1767

循环结的计算

余数检测法:模拟除法,比如我们要计算1/7这个小数的循环节,求第一组的余数r,不难得r=1%7=1,然后将r*10继续取余 r=(1×10)%7=3,每次求出一组余数的数据,我们需要判断一下:所求出的余数之前有没有出现过,只有余数出现过,那就说明循环节出现了,(余数为0时,说明不循环),然后我们记录循环节的位置pos(第一次出现的位置),在之后把从0到pos(不包括pos)之前的数据单独输出,这一...

雨羊的博客 847

FDTD超表面仿真详细教程,几何相位,共振相位,传播相位

FDTD的超表面主要几何相位型(PB型)和共振型两种类型,其中PB型每个cell中的纳米棒的长宽相同,旋转角度不同,共振型长宽不同,旋转角度相同。本博文中以最常见的长方形纳米棒为例,用FDTD演示两种超表面实现的聚焦透镜的功能,包含详细步骤,其他形状,材料的超表面可自行尝试。

wuyuerhhg的博客 3万+

IC设计新手必看:如何正确使用去耦电容(decap)避免电源噪声?

本文深入探讨了IC设计中去耦电容(decap)的应用技巧,从核心原理到布局实现,帮助新手工程师有效抑制电源噪声。文章详细解析了MIM、MOM等电容类型的特性与选择策略,并提供了先进的布局技巧和验证方法,特别适用于28nm以下先进工艺的电路设计挑战。

weixin_30555125的博客 114

【POJ 1961】Period(KMP求循环节)

【POJ 1961】Period(KMP求循环节) Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 15466   Accepted: 7417 Description For each prefix of a given string S with N cha

ACMer' 1083

国民技术N32G45X低功耗问题之更改全局变量和栈在RAM中的地址

最近项目中用的MCU是国民技术的N32G45X,MCU的资源很丰富,RAM也很大,配套的库和例程也比较全,用起来还是不错的,但是在调试低功耗的时候还是费了不少劲。 首先由于项目低功耗需要,只能选择停机模式2(STOP2)。根据数据手册的描述,在此模式下外部低速时钟开启, RTC运行, R-SRAM保持,所有I/O状态保持,独立看门狗处于关闭状态,25℃的条件下电流为10个微安。 用的这款MCU的RAM是144KB,分为SRAM(128KB)和R-SRAM( Retention SRAM – 16KB),如果

狂想家 2485

POJ 1961 Period kmp求循环节

题目:http://poj.org/problem?id=1961 题意:给定一个字符串,判断字符串从开头到每个字符之间的一段字符串有没有形成循环,若有循环,输出这个位置及循环次数 思路:用kmp算法求循环节,记得判断一下循环次数为1的情况,这种情况不是循环 #include #include #include #include using namespace std; const

弱智就要多努力 623

DEM高程数据的获取、合并与坐标转换

DEM高程数据的获取、合并与坐标转换一、DEM数据的获取二、数据合并三、投影转换方法一四、投影转换方法二 今天用DEM数据做了一个坡度分析,数据使用过程中涉及到投影坐标转换,由于不是很熟悉所以费了一番功夫。经过一番折腾总结出两个方法,方法一自认为比较便捷的方法,即通过BIGMAP软件中工具列表中的投影转换功能进行。方法二为传统方法,即在Arcgis中用投影栅格工具进行转换。 一、DEM数据的获取 在地理空间数据云网站下载DEM数据(精度包括30米和90米),数据格式为tif格式或img格式,坐标为WGS_1

weixin_48625651的博客 1万+

Robosuite与Robomimic:机器人学习的黄金搭档

本文深入探讨了Robosuite与Robomimic这对机器人学习的黄金组合,详细介绍了如何利用Robosuite进行物理仿真和任务环境构建,以及Robomimic在演示数据处理和离线学习算法实现中的应用。通过实际案例和代码示例,展示了从仿真环境搭建到模型训练的全流程,帮助研究人员高效开展机器人学习实验。

weixin_29178069的博客 415

POJ_1961 Period ( KMP求循环节 )

题目连接 题意 每组给出一个长度为 n 的字符串, 要求输出这个字符串每个前缀为 i 时的最短循环节, 换句话说就是遍历这个字符串, 输出 i 和 长度为 i 的时候子串循环的次数 题解 如果 i%(i-next[i])==0 那么就有循环 循环次数为 i/(i-next[i]) 循环长度为 i-next[i] 例如:aabaabaabaab 当 i=2 时,前缀为 aa,是由于 a 重复两次得到...

♡ 脚下的每一步都叫远方 ♡ 192

MATLAB 基于深度学习的步态识别算法仿真

步态识别是一种通过分析人体行走方式来识别身份的技术。基于深度学习的步态识别算法利用卷积神经网络 (CNN) 提取步态特征,并通过分类器进行身份识别。基于深度学习的步态识别算法是实现身份识别的重要手段,具有广泛的应用前景。MATLAB 提供了丰富的工具和函数,可以方便地进行算法仿真和性能评估。

走向CTO的路上... 518

poj1961 Period(KMP求周期性循环节)

题意:给你一个字符串,然后让你看看有没有前缀的循环节大于1,如果有,输出前缀的长度和循环节大小。 思路:判断字符串是否是周期性字符串:i % (i - Next[i] )==0 ,循环节长度 i - Next[i] ,循环节出现次数为 i / (i - Next[i])。 AC Code: #include<iostream> #include<cstring> ...

一身清贫怎敢入繁华 505

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

POJ - 1961 Period(KMP求最短循环节)

PeriodTime Limit: 3000MS Memory Limit: 30000KDescriptionFor each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether...

x__1998的博客 597

深度学习工具包 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")

POJ 1961 Period——kmp求最小循环节

就是kmp求最小循环节在套一个循环,关于kmp求最小循环节请看 http://blog.youkuaiyun.com/hao_zong_yin/article/details/77455285 #include #include #include #include using namespace std; const int maxn = 1e6 + 10; char p[maxn]; int

hao_zong_yin的博客 647

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

POJ - 1961 Period (KMP next数组求循环节)

题目描述 给定长度为n的字符串, 求串中某个点的前缀中的循环节最多有多少个 样例 Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output Test case #1 2 2 3 3 Test case #2 2 2 6 2 9 3 12 4 思路 我们知道, KMP中的next数组,next[j] 代表j的前缀和从后面开始, 长度为j的串相等, ...

正月看雪花的博客 195

Period POJ - 1961(kmp求最大周期,最小循环节)

For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2

w571523631的博客 575

【 poj 1961 】Period 【KMP 求所有前缀的循环节】

For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <

lzs_lazy 324

KMP 求最小循环节 POJ - 1961 Period

Problem Description 给你一个整数n,接下里有n个字符的字符串,到第i个字符的时候判断周期是否大于2,如果大于2同时是循环字符串,输出相应的长度,和循环了几次。 Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output Test case #1 2 2

ACMer 梁剑锋 的博客 582

poj1961--Period(KMP求最小循环节)

Period Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 13511   Accepted: 6368 Description For each prefix of a given string S with N characters (each character

随风的专栏 1161

Period POJ - 1961 (kmp利用next数组求最小循环节)

题意:给定一个字符串,ascii码在97到126之间(字母)如果前i个字符组成的字符串是由子字符串循环一定次数组成的,则该字符串为周期串,子字符串为循环节。 比如aabaabaabaab,在前两个字符中a出现了两次,循环节为a。在前6个字符中,循环节出现了2次,循环节为aab,在前9个字符中,循环节出现了3次,循环节为aab;在12个字符中循环节出现了4次,循环节为aab。请编程写出给定字符串的n长度的周期串以及循环节出现的次数。 题解:结论若len%(len-next[len])==0则len-next

Alanrookie的博客 307

【KMP算法】【最小循环节】讲解 + 例题 POJ 1961 Period 【给字符串s,求s的具有循环节的前缀,并输出所有前缀长,循环节个数】

【KMP算法】【最小循环节】讲解 + 例题 POJ 1961 Period 【给字符串s,求s的具有循环节的前缀,并输出所有前缀长,循环节个数】 摘自 KMP最小循环节 一、定理 假设S的长度为len,若S存在最小循环节,循环节的长度c_L = len-next[len],子串为S[0…len-next[len]-1]。 c_l表示cycle_len。 (1)如果len %...

Floraqiu的博客 1901

LA 3026 && POJ 1961 Period(KMP求前缀的最短循环节)

题意: 给定一个长度为n 的字符串s,求它的每个前缀的最短循环节? 思路: 我们想一下KMP的next 函数。 next[i]表示 由S[0],S[1],,,,S[i] 构成的字符串的最大前缀长度 使得前缀等于后缀。 那么这个问题就很好办了。 假设当前枚举到i 位置了。(目前字符串的长度是i) 假设最短循环节是X。 那么next[i] 一定是i - X; 所以我们只需要判断i 是

aozil_yang的博客 574

Poj1961--Period(Kmp, Next数组求循环节长度 && 出现次数) & Poj 2406--Power Strings

Period Time Limit:3000MS Memory Limit:30000K Total Submissions:14657 Accepted:6967 Description For each prefix of a given string S with N characters (each character...

weixin_34194379的博客 76

poj 1961 Period(KMP, 最短循环节)

题目链接: POJ  : http://poj.org/problem?id=1961 HDU : http://acm.hdu.edu.cn/showproblem.php?pid=1358 ZOJ   : http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2177 题目大意: 给定一个长度为n的字符串s,

D_Double's Journey 1875
上一篇: poj2406 Power Strings 简单KMP
下一篇: 一些资源汇总,持续更新
Forjames
博客等级 码龄11年 1粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值