String Problem HDU - 3374 (最大最小表示法)

Problem E: 求最大值和最小值 Description 求出一些整数中的最大值和最小值。 Input 输入为多行,以EOF结束。每行为一个十进制的数字,全部由0~9组成,每行最长不超过1000个字符。有些数字会以0开头(不影响数值大小的前导0)。 Output 输出为输入中的最大值和最小值,格式见sample。 Sample Input 02010001201223 Sample Ou 阅读详情

String Problem

HDU - 3374

Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings:
String Rank
SKYLONG 1
KYLONGS 2
YLONGSK 3
LONGSKY 4
ONGSKYL 5
NGSKYLO 6
GSKYLON 7
and lexicographically first of them is GSKYLON, lexicographically last is YLONGSK, both of them appear only once.
  Your task is easy, calculate the lexicographically fisrt string’s Rank (if there are multiple answers, choose the smallest one), its times, lexicographically last string’s Rank (if there are multiple answers, choose the smallest one), and its times also.

Input
  Each line contains one line the string S with length N (N <= 1000000) formed by lower case letters.
Output
Output four integers separated by one space, lexicographically fisrt string’s Rank (if there are multiple answers, choose the smallest one), the string’s times in the N generated strings, lexicographically last string’s Rank (if there are multiple answers, choose the smallest one), and its times also.
Sample Input
abcder
aaaaaa
ababab
Sample Output
1 1 6 1
1 6 1 6
1 3 2 3

关于字符串最小最大表示法讲解:点击打开链接

模板:点击打开链接

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#define N 1000005
using namespace std;
char s[N];
int Next[N];
void getNext(){
    int i = -1,j = 0;
    memset(Next,0,sizeof(Next));
    Next[0] = -1;
    int len = strlen(s);
    while(j < len){
        if(i == -1 || s[i] == s[j]){
            i++,j++;
            Next[j] = i;
        }
        else{
            i = Next[i];
        }
    }
}
int min_max_express(bool flag){
    int i = 0,j = 1, k = 0;
    int len = strlen(s);
    while(i < len && j < len && k < len){
        int t = s[(j+k)%len]-s[(i+k)%len];
        if(t == 0)
            k++;
        else{
            if(flag){
                if(t > 0) j = j+k+1;
                else i = i+k+1;
            }
            else{
                if(t > 0) i = i+k+1;
                else j = j+k+1;
            }
            if(i == j) j++;
            k = 0;
        }
    }
    int ans = min(i,j);
    return ans;
}
int main(){
    while(~scanf("%s",s)){
        getNext();
        int mins = min_max_express(true);
        int maxs = min_max_express(false);
        int len = strlen(s);
        int tmp = len-Next[len];
        int times = len % tmp ? 1 : len/tmp;
        printf("%d %d %d %d\n",mins+1,times,maxs+1,times);
    }
    return 0;
}


ros2 humble中使用realsense t265与d435 前提,安装realsense SDK 2.51.1版本并且能成功启动realsense-viewer V2.51.1想要在ros2中使用realsense t265,必须配合realsense SDK v2.51.1使用realsense-ros 4.51.1版本,因为新版本realsense ros2不再对t265支持下面记录源码编译安装 realsense-ros 4.51.1版本。 阅读详情

相关推荐

深入解析Xilinx IDELAYE2在FPGA时序优化中的关键作用与实战配置

本文深入解析了Xilinx FPGA中IDELAYE2模块在时序优化中的关键作用。作为精密的信号延时微调器,IDELAYE2通过可编程的抽头延迟,有效解决高速接口中数据与时钟的相位偏差问题。文章详细阐述了其必须与IDELAYCTRL配对使用的核心机制,并对比分析了FIXED、VARIABLE和VAR_LOAD三种工作模式的实战配置方法与代码示例,为FPGA工程师提供了解决时序收敛难题的关键硬件配置指南。

pear55的博客 1183

2015广工校赛 Problem E: GDUT的实验室

Problem E: GDUT的实验室Description众所周知,我们GUDT的集训队实验室很高大上,里面拉有千兆光纤,下载速度高达***M/s…但是问题来了,我们都知道每台电脑都会被分配一个IP地址,这些IP地址形如A.B.C.D,但是机器只懂得二进制,它会将IP地址读成二进制的地址(仅有1和0),但机器难免会出点问题,现在给你一个十进制的IP地址,再给你一个机器翻译后的二进制的IP地址,问这

围巾的ACM博客 827

2025.1.16——五、LoveSQL1 sqlmap文件类|万能密码

题目来源:BUUCTF[极客大挑战2019]LoveSQL1。

2402_87387800的博客 1066

String Problem HDU - 3374(字符串的最大最小表示)

Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONG

码农的一亩三分地 337

linux CentOS7安装VCS、Verdi、SCL

1.Linux下所需安装文件 链接:https://pan.baidu.com/s/1E_l4ARFYEnp57jlX95Bpog 提取码:ggdz ​ synopsysinstaller_v5.0 ​ scl_v2018.06 ​ vcs_mx_vO-2018.09-SP2 ​ vcs_vO-2018.09-SP2 ​ verdi-2018.9 2.Windows破解文件 ​ scl_keygen_2030 3.安装installer 打开终端,进入synopsysinstaller_

loveyelong的博客 4618

Python实现高光谱图像生成与增强:从RGB到多光谱转换(附完整代码)

本文分享一个基于Python的实用工具,能够将普通RGB图像转换为模拟高光谱图像,并进一步生成增强的彩色可见图像。为了直观展示图像细节,程序通过对特定波段的组合,生成了一幅增强的 RGB 彩色图像。该函数的主要目标是将一张普通的 RGB 图像转换为包含多个波段的高光谱图像。通过该函数,我们能直观地看到高光谱图像经过波段组合后所得到的彩色图像效果。通过以上代码,我们可以实现对海量图像数据的自动化处理,极大地提升工作效率。已附在文中,欢迎下载测试!通过以上步骤,我们可以生成一幅包含多个光谱波段信息的图像。

m0_74824642的博客 3665

String Problem HDU - 3374 (KMP+最小表示法)

Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings:  String Rank  SKYLONG 1  KYLONGS 2  YLONGSK 3...

Top_Spirit的博客 259

PyTorch深度学习实战(7)——批大小对神经网络训练的影响

在神经网络中,批( batch )是指一次输入网络进行训练或推断的一组样本。批处理( batch processing )是指将这一组样本同时输入网络进行计算的操作。本节中首先介绍批( Batch )的基本概念,并且介绍批大小在神经网络训练过程中的影响。

盼小辉丶的博客 1万+

String Problem HDU - 3374

http://acm.hdu.edu.cn/showproblem.php?pid=3374 详解https://wenku.baidu.com/view/b0ef1be7a6c30c2258019ede.html 字符串最大最小表示法 求出起始位置 #include &lt;bits/stdc++.h&gt; using namespace std; int go[1000010]; ...

sunyutian1998的博客 315

数字电路逻辑与设计实验三 译码器和数据选择器

1. 译码器功能测试 将 74LS139 按图 3.1 接线,按表 3.2 输入电平分别置位,填输出状态表。 2. 译码器转换 将双 2-4 线译码器转换为 3-8 线译码器。 (1)画出转换电路图。 (2)在实验箱上接线并验证设计是否正确。 (3)设计并填表写该 3-8 线译码器功能表,画出输入、输出波形。 3. 数据选择器的测试及应用 (1) 将双 4 选 1 数据选择器 74LS153 参照图 3.2 接线,测试其功能并填写功能表 3.3。 (2)将实验箱脉冲信号源中固定连续脉冲 4 个不

欢迎交流学习心得 3085

全面绩效管理:提升整体效能

《全面绩效管理:提升整体效能》 关键词:绩效管理、整体效能、团队绩效、个体绩效、领导力、数字化转型 摘要:本文从绩效管理的基础概念入手,深入探讨了绩效管理体系构建、绩效指标

AI天才研究院 604

hdu 3374 String Problem (最大最小表示法)

http://acm.hdu.edu.cn/showproblem.php?pid=3374 SKYLONG 1 KYLONGS 2 YLONGSK 3 LONGSKY 4 ONGSKYL 5 NGSKYLO 6 GSKYLON 7 题意:输出的是最小字典序的编号,最小字典序个数,最大字典序编号,最大字典序个数 求有几个这样的字符串直接Kmp求得next数组就ok了, 然后

大太阳 786

RK3568平台开发系列讲解(项目篇)手写数字识别

📢 本篇章带大家基于飞桨(PaddlePaddle),完成一个简单的手写数字识别任务。

内核笔记 1182

hdu3374String Problem kmp+最大最小表示法

//给出一个序列,求其最大最小表示法的最小位置 //并且求出有多少这样的最小最大表示法 //对于次数,就是循环节的个数,用kmp就能求出来 #include #include #include #include using namespace std ; const int maxn = 1e6+10 ; string str

ijbuhv的专栏 585

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

假人有限元模型

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

HDU 3374 String Problem(最大最小表示法 模板题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3374Problem DescriptionGive you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can ...

1670

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

HDU 3374 String Problem(最大最小表示法+kmp)

Time Limit:1000MS Memory Limit:32768KBDescription Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven s

2cm的专栏 490

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

HDU 3374 String Problem 字符串最大最小表示法 模板题

Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK...

zhangjinlei321的博客 317

N - String Problem HDU - 3374(最大最小表示法模板)

String Problem HDU - 3374 题意:给你一个字符串,让你求他的循环串的最大最小的位置,以及出现次数。 分析:出现次数很好求了,你可想如果最大最小出现多次即存在循环串,才有可能有多个最大最小。然后就是最大最小表示法的模板存一下。 #include <iostream> #include <cstdio> #include <stack&g...

fighting_yifeng的博客 262

HDU - 3374 String Problem 求字符串的最大最小表示法 并求循环次数

HDU - 3374 String Problem 题意: 给你一串字符,这串字符可以左移(将最前面一个字符放到字符串最后面)生成 strlen(s) 个字符串,求出其中字典序最小 和 最大 的字符串在原串的起始位置和出现的次数(如果存在多个最小或最大串,则输出rank值小的,即下标小的那个)。 输出:最小字符串起始位置 出现次数 最大字符串起始位置 出现次数 思路: ...

没有梦想何以远行 235

HDU3374 String Problem(kmp,最大最小表示法)

Problem Description Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLON

riba2534的博客 729

Hdu 3374 String Problem(KMP+字符串最大最小表示法)

Hdu 3374 题意:给你一个字符串,让你输出它移位后最小字典序的rank和循环节个数,最大字典序的rank和循环节个数。 题解:循环节好找,只要判断len%(len-nx[len])是否等于0,如果等于0说明含有循环节,则ans=len%(len-nx[len]),否则ans=1(即循环节为一整个字符串)。最小字典序和最大字典序的rank其实就是其首在原字符串的下标+1。做的时候去学习了一...

weixin_30706507的博客 124

HDU 3374 String Problem (KMP+最大最小表示法)

题意:输出目标字符串最小表示的下标和数量,最大表示的下标和数量 题解:最大最小表示法模板题,数量也好求,用KMP的next数组求循环节即可(字符串循环节) #include<cstring> #include<cstdio> using namespace std; const int maxn=1000010; char s[maxn]; in...

aomen8092的博客 166

HDU - 3374——String Problem (最大最小表示法)

Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strings: String Rank SKYLONG 1 KYLONGS 2 YLONGSK 3...

creator平 328

String Problem HDU - 3374 KMP+字符串的最大最小表示法

做这个题前首先要明白字符串的最大最小表示法,我一开始也不会,看了题解也是一脸懵,附上一篇讲解字符串的最大最小表示法的博客链接(67条消息) 字符串处理 —— 最大最小表示法_Alex_McAvoy的博客-优快云博客,在这里感谢大佬指点迷津,orz 题意:每次给你一个字符串,如果字符串的长度为n,那你可以进行n次操作,每次操作都可以把一个字符从左边第一个移动到右边最后一个,因此你会得到n个字符串,问这n个字符串中字典序最小和最大的字符串排在第几个(如果有多个字典序最小或最大的字符串有多个,那么就.

weixin_54562114的博客 159

HDU 3374String Problem(最大最小表示法+KMP)

String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1292    Accepted Submission(s): 581 Problem Description Give you a s

布生气 2122

HDU - 3374 String Problem (kmp求循环节+最大最小表示法)

做一个高产的菜鸡 传送门:HDU - 3374 题意:多组输入,给你一个字符串,求它最小和最大表示法出现的位置和次数。 题解:刚刚学会最大最小表示法,amazing.. 次数就是最小循环节循环的次数。 #include<bits/stdc++.h> using namespace std; int nt[1000100],b[1000100]; char a[100010...

只能过样例嘤嘤嘤的博客 167
上一篇: Corporate Identity HDU - 2328 (kmp+枚举)
下一篇: How many HDU - 2609 (最小表示法)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值