HDU-2609 How many (最小表示法)

基于虚拟阻抗重塑的构网型VSG变流器SISO序阻抗建模与宽频振荡抑制策略分析(面向高比例新能源并网场景) 本文深入探讨了基于虚拟阻抗控制的构网型VSG变流器SISO序阻抗建模技术及其在高比例新能源并网场景中的宽频振荡抑制策略。通过虚拟阻抗重塑,有效改善了变流器的阻抗特性,解决了次/超同步频段的振荡问题,并提供了参数设计、阻抗扫频验证等实用技巧,为新能源并网系统的稳定性提供了可靠解决方案。 阅读详情

题目:

http://acm.hdu.edu.cn/showproblem.php?pid=2609

题意:

给出n个0/1串,通过循环可以相同的串算一类,求一共有几类串。

思路:

暴力点写就是把所有串都变成最小表示法,然后排个序扫一遍就行了。

代码:

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPS 1e-6
#define N 1123456
using namespace std;
int n,m,sum,res,flag;
char s[101],ss[101];
int minString(char *s)
{
    int i=0,j=1,k=0;
    int len=strlen(s);
    while(i<len&&j<len&&k<len)
    {
        if(s[(i+k)%len]==s[(j+k)%len])k++;
        else
        {
            if(s[(i+k)%len]>s[(j+k)%len])i=i+k+1;
            else j=j+k+1;
            if(i==j)j++;
            k=0;
        }
    }
    return i<j?i:j;
}
int main()
{
    int i,j,k,kk,cas,T,t,x,y,z;
    vector<string>sn;
    while(scanf("%d",&n)!=EOF)
    {
        sn.clear();
        for(i=0;i<n;i++)
        {
            scanf("%s",s);
            m=strlen(s);
            t=minString(s);
            for(j=0;j<m;j++)
                ss[j]=s[(j+t)%m];
            string st(ss);
            sn.push_back(st);
        }
        sort(sn.begin(),sn.end());
        res=1;
        for(i=1;i<n;i++)
            if(sn[i]!=sn[i-1])
                res++;
        printf("%d\n",res);
    }
    return 0;
}










RISC-V V向量指令集学习笔记——访存指令 阅读详情

相关推荐

同济大学C++mooc第五、六讲参考答案

同济大学C++moooc第5、6讲 第五讲 第一题 随机产生10个30~100(包括30,100)的正整数,求它们的最大值、最小值、平均值,并显示整个数组的值和结果。 代码片. // #include<iostream> const int n = 10; using namespace std; int main() { int s[n],i,j,t,sum=0; for (i = 0; i < n; i++)

cjzui6666的博客 1万+

hdu2609(字符串个数)

Give you n ( n &lt; 10000) necklaces ,the length of necklace will not large than 100,tell me  How many kinds of necklaces total have.(if two necklaces can equal by rotating ,we say the two necklaces a...

qq_40859951的博客 263

从CAD图纸到GIS地图:手把手教你用Global Mapper处理DWG文件(含坐标配准)

本文详细介绍了如何使用Global Mapper将CAD图纸(DWG文件)转换为GIS地图,包括坐标配准、图层与属性转换等关键步骤。通过四参数变换和控制点匹配技术,确保数据精准转换,适用于测绘、城市规划等领域。文章还提供了高级处理技巧和质量控制流程,帮助用户高效完成GIS化工作。

weixin_29196891的博客 529

How many HDU - 2609(最小表示法模板题)(SET应用)

HDU - 2609 题意分析: 给你一组字符串,让你找到有多少个是同一类的字符串,规则是,每个字符串如果经过翻转(第一个放在最后一个,以此类推)能相等,那么就说这两个是同一类。 解题思路: 根据题意,我们可以想到,如果是同一类的字符串,那么他们的最小表示法或者最大表示法一定是相等的,如果我们求出来了,最小表示法,然后放到SET容器里面进行去重,那么最后set的长度就是答案 最小表示法可以参考:最小表示法 最小表示法的模板: int getmin(char *s){ int n=strlen(s);

lymww的博客 198

k最近邻算法——电影分类及案例详解

如图3-7所示,若将国际象棋棋盘放在二维直角坐标系中,格子的边长定义为1,坐标的x轴及y轴和棋盘方格平行,原点恰落在某一格的中心点,则王从一个位置走到其他位置需要的步数恰为二个位置的切比雪夫距离,因此切比雪夫距离也称为棋盘距离。关于这里的距离度量,这个电影分类的例子有2个特征,也就是2维的,可以使用我们高中学过的两点距离公式(两点距离公式其实就是欧氏距离在二维空间上的公式,也就是欧氏距离n的值为2的情况,欧氏距离也称为欧几里德距离)来计算距离,如图3-3所示。对数据进行归一化,避免量纲对计算距离的影响。

ZhShy 4566

Claude Code vs Codex实战对比:哪个更适合你的Next.js项目?(含真实案例)

本文通过两个真实的Next.js项目案例,深度对比了Claude Code与Codex在UI实现和业务逻辑构建中的表现。Claude Code在代码质量、设计还原度和架构完整性方面优势明显,适合对可维护性要求高的生产级项目;而Codex则以快速响应和低成本见长,更适合原型开发或内部工具。文章提供了基于项目类型、团队能力和成本效益的详细选择策略。

weixin_29201859的博客 817

HDU - 2609 How many(最小表示法)

HDU - 2609 How many(最小表示法) #include<iostream> #include<set> using namespace std; int get_min(string s,int n) { int k=0,i=0,j=1; while(k<n&&i<n&&j<n) { if(s[(i+k)%n]==s[(j+k)%n]) k++; else { if(s[(i+k)%n]&gt

00后的博客 180

点到面点云配准(Point To Plane)算法知识详解和详细推导,C++代码实现

点到面 ICP (Iterative Closest Point) 是在 3D 点云配准中常见的一种变体,通过最小化点到对应面(由法向量定义的局部平面)的距离来提高收敛速度和精度。

qq_36812406的博客 1818

POJ 2609 DP 双队列DP

动态规划解决双队列问题

_int_me的博客 221

Pytest教程:Pytest插件原理

Pytest的插件系统是其强大功能的核心,它允许用户和开发者扩展和定制测试框架的行为。要深入理解Pytest插件的原理,我们需要从Pytest的架构和设计模式开始,然后深入到底层源码。

旦莫的博客 639

【FPGA教程案例59】深度学习案例6——基于FPGA的CNN卷积神经网络之整体实现

在课程,我们对的基本原理有了初步认识。在上一个课程,我们完成了CNN的Relu激活层、pool池化层、卷积层以及图像输入层的实现,如下图所示:在本课程中,我们将上述四个模块结合起来,构建一个简单的CNN卷积神经网络。...

FPGA/MATLAB学习教程/源码/项目合作开发 2640

HDU 3374 最小 / 大表示法

题意 传送门 HDU 3374 String Problem 题解 求字符串中字典序最小与最大的循环同构串,并求解对应的起始字符在原字符串中出现的位置最早的一个,以及这个循环同构串出现的次数。 最小/大表示法 字符串字典序最小/大的循环同构串称为字符串的最小/大表示。设字符串 SSS 长度为 nnn,最小/大表示法的可以 O(n)O(n)O(n) 求解,区别只在于字典序的判断。以最小表示法的求解为例,将原串 SSS 复制一份接在其结尾,得到的字符串记为 SSSSSS,则有 SS[i,i+n),i∈[0,n)

neweryyy的博客 202

【Pix4d精品教程】pix4d mapper相机未校准后手动添加连接点完美案例图文教程

如图所示,红色的照片为未校准的图片,软件无法自动获取连接点,有关相机未校准的原因及解决办法,可以参考《pix4d未校准相机:287 out of 402 images calibrated (71%), all images enabled, 6 block,问题分析及解决方案汇总》,本文以案例的形式,详细讲解pix4d中手动添加连接点的方法及操作步骤。 文章目录1. 手动添加连接点2. 重新优化3. 生成质量报告,检查精度 1. 手动添加连接点 在【空三射线】模式下查看校准失败的图片,记下照片的名称。.

智慧空间实验室 2万+

HDU2609 How many —— 最小表示法

题目链接:https://vjudge.net/problem/HDU-2609 How many Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3272Accepted Submission(s): 1457...

alince20008的博客 152

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

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

HDU - 2609 How many 最小表示法应用

HDU - 2609 How many 题意: 给你n串项链(字符串可以左移),判断有多少种不同的项链 思路: 最小表示法+set 如果这些长度相同的字符串通过旋转后相同,则他们的最小表示法一定相同,最后set的大小即为不同的串数。 substr是C++语言函数,主要功能是复制子字符串,要求从指定位置开始,并具有指定的长度。如果没有指定长度_Count或_Count+_Off超出了源字...

没有梦想何以远行 280

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

最小表示法+hash hdu2609 How many

传送门:点击打开链接 题意:有n个串,每个串是一个环,如果通过移动环之后能一样,认为是同一种串。问有多少种串。 思路:很明显我们首先要把认为是一样的串变成一样的,比如找到这个串的最小表示法,所以这道题的目的就是为了求最小表示法,然后用hash搞一搞排序然后去重,或者是直接插入到set里面取size都是可以的 KMP(复杂度O(n))来搞最小表示法暂时还不会,先挖个坑,我这里还有一种通过二分+

qwb的博客 1461

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

HDU 2609 How many【最小表示法】

How many 传送门。 题意: 多组输入 每组一个n,串串个数 通过首尾相连可以相同的串算一类,求一共有几类串。 For example 011001100110 express a necklace, you can rotate it. 0110−&gt;1100−&gt;1001−&gt;0011−&gt;0110.0110 -&gt; 110...

zhmeng 256

[最小表示法] hdu 2609 How many

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2609 How many Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1225    Accepted Submis

cc_again的专栏 1171

【题解】How many HDU - 2609 ⭐⭐⭐ 【最小表示法】

How many HDU - 2609 The input contains multiple test cases. Each test case include: first one integers n. (2<=n<=10000) Next n lines follow. Each line has a equal length character string. (strin...

Suprit's blog 703

[最小表示法] HDU 2609 How many

题意: 给n个串,问不断的循环左移之后,有几个不相同的串。 思路: 全部转换的成字符串的最小表示法,统计。 裸题存模板 代码: #include"cstdlib" #include"cstdio" #include"cstring" #include"cmath" #include"queue" #include"algorithm" #include"iostream" #inclu

Enmity_Dark 808

hdu 2609 How many(最小表示法)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题意:给你n个字符串每个字符串可以左右移动但还是同一串比如0110 可以表示为 0110 -> 1100 -> 1001 -> 0011->0110 这些都属于同一个字符串,最后问这n个字符串里一共有多少不同的字符串 可以将这些字符串都以其最小表示...

awow80285的博客 124

hdu2609How many 最小表示法

//n(n<=10000)个字符串,字符串的长度l<=100 //问这n个字符串中有多少不同得字符串 //两个字符串相同只要其循环同构 //先求出每个字符串的最小表示法 //用map存下就行 #include #include #include #include using namespace std ; const int maxn = 1e4+10 ; map ma ; string str

ijbuhv的专栏 578

HDU 2609 How many [最小表示法]

Description给n个字符串,如果循环同构,就算一组,问总共有几组Algorithm将每个字符串转成最小表示,然后sort一下Code#include <cstdio> #include <algorithm> #include <iostream> using namespace std; const int maxn = 100010; int main() { int n; wh

more time 576

HDU 2609 How many(最小表示法)

Problem Description Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell meHow many kinds of necklaces total have.(if two necklaces can equal by rotating ,we...

weixin_30780221的博客 108

hdu 2609 How many (最小表示法)

题意 给 \(n\) 个循环串,求本质不同串的数量 传送门 思路 最小表示法求下标,从最小下标处作为串的起点,将新串放到map中去重,最终map中的元素数量即为最终答案。 最小/大表示法 Code #include <cstdio> #include <cstring> #include <map> #include <string> u...

diaozha3808的博客 238

HDU 2609 How many(最小表示法)

题目链接:HDU 2609 How many 题目大意: 有n个有01组成的字符串,每个字符串都代表一个项链,那么该字符串就是一个环状的结构,求可以经过循环旋转,最后不同的串有多少个。 算法思想: 将每个字符串转换成最小串,然后放在set里面去重。 最小表示法: 循环字符串的最小表示法的问题可以这样描述: 对于一个字符串S,求S的循环的同构字符串S’中字典序最小的一个。

Winjourn的专栏 883
上一篇: HDU-1358 Period (kmp)
下一篇: HDU-3613 Best Reward (Manacher)
kopyh
博客等级 码龄12年 20粉丝 152原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值