38. Count and Say

Matlab SSIM图像质量评价源码逐行注释与参数避坑 图像质量评价用于衡量压缩、去噪、超分、配准等处理后的视觉保真度。PSNR 只统计逐像素误差,对结构退化不敏感;SSIM 则从亮度、对比度和结构出发,在局部滑动窗口内比较图像相似性,更贴近人眼对边缘和纹理的判断。Matlab 中借助 imfilter、高斯加权核和向量化运算,可高效计算 SSIM 图与 MSSIM 均值。理解 C1/C2 常数、L 动态范围、边界填充和窗口/sigma 匹配,是避免分数失真、NaN 与结果偏差的关键。该指标常用于课程设计、算法对比和工程评测,把 PSNR 与 MSSIM 联合使 阅读详情

1. 1

2. 1中由于有一个1,故2表示为11

3.2中由于有二个1,故3表示为21

4.3中由于有一个2,一个1,故4表示为1211

5.4中由于有一个1,一个2,二个1,故5表示为111221

6.同理6表示为312211

7.同理7表示为13112221

 

在上述规律的基础上,循环计算可得N的表示法:

class Solution {
public:
    string countAndSay(int n) {
        string res="";
        string s="1";
        
        if(n==1)
            return s;
        
        for(int i=1;i<n;i++)
        {
            int count=1;
            string temp="";
            for(int j=0;j<s.length();j++)
            {
                while(s[j]==s[j+1])
                {
                    j++;
                    count++;
                }
                
                temp=temp+(char)(count+'0')+s[j];
                count=1;
            }
            
            res=temp;
            s=temp;
        }
        return res;
    }
};

 

单片机多级菜单的简单实现 单片机多级菜单的简单实现 多级菜单的思路 最近想把stm32上的oled显示屏做的好看一些,于是动手写了写一个多级菜单,思路很简单,每个页面用单独的函数封装好,每个功能也是用单独的函数进行封装,用了3个按键,两个切换键,一个确定键。 首先来看看用啥判断页面的(这偷个懒,希望没人打我) //页面标志位 uint8_t s1 = 0; //主页面功能号 uint8_t s2 = 0; //主次页面判断标志位 uint16_t s3 = 1; //次页面功能号 主页面的显示函数,这是个很枯燥的一 阅读详情

相关推荐

微信公众号数据采集实战:历史文章、互动数据与评论详情全解析

本文提供了一套完整的微信公众号数据采集实战方案,详细解析了如何通过接口调用获取公众号的历史文章列表、单篇文章的互动数据以及详细的用户评论。文章从环境准备、核心参数解析到分页逻辑、批量处理和异常处理,提供了可运行的Python代码示例,旨在帮助开发者高效、稳定地构建自动化采集工具,用于竞品分析、内容研究和舆情监控。

u5v6w7的博客 1602

LeetCode38——Count and Say

LeetCode38——Count and Say 上一题对我来说实在太凶残了,所以我还是缓缓先做38题好了。。。 题意: 可以理解为求一个数组的第n项,而这个数组的通项公式可以这样理解: 第1项:1 第2项:11 第3项:21 第4项:1211 第5项:111221 第6项:312211 ... ... 第n项:第n-1项的数字串从左到右读出来。

上善若水 4489

信息系统项目管理(三)软件工程相关知识

软件工程是指应用计算机科学、数学及管理科学等原理,以工程化的原则和方法来解决软件问题的工程,其目的是提高软件生成率、提高软件质量、降低软件成本。 一、需求分析 软件需求是指用户对新系统在功能、行为、性能、设计约束等方面的期望。 1.1 软件需求层次 软件的需求主要分为三个层次,从低到高依次是系统需求、用户需求和业务需求 1.1.1 系统需求 系统需求主要是从系统角度来说明软件需求,包括功能需求、非功能需求和设计约束 功能需求:规定开发人员必须在系统中实现的软件功能,满足业务需要 非功能需求:系统必须具备的

hello_1566的博客 5460

Leetcode1-100: 38. Count and Say

Leetcode1-100: 38. Count and Say问题描述解题思路代码实现 问题描述 题目要求: 输入一个数字,输出这个数字代表的count-and-say字符串,注意每个数字对应的字符串需要根据上一个数字的字符串来得出(例如4对应的是1211,就是1个1,1个2,2个1,所以5对应的字符串就是111221) 解题思路 比较简单,直接brute force,迭代从1往后解,每次把上一个的结果最后下一个的输入来做即可。 代码实现 public String countAndSay(int n)

Y123iwantit的博客 301

Windows下构建ImGui.Net

工具 Visual Studio 2017 操作 下载项目 git clone https://github.com/mellinoe/ImGui.NET.git 编译 右键以下两个项目并调试: ImGui.NET.SampleProgram ImGui.NET.SampleProgram.XNA Error fix 中间遇到一些问题: SDK版本不对 去微软官网下载安装对应版本 由于设置了代理被远程服务器拒绝连接 关闭代理(也许在环境变量中) nuget源无对应资源,404 NOT FOUN

jojozym的博客 1489

R语言新手也能搞定!WGCNA分析全流程代码详解(附常见报错解决方案)

本文为R语言新手提供了WGCNA分析的完整代码流程与实战指南。从环境配置、数据准备、软阈值选择、网络构建到模块-表型关联分析,逐步详解核心步骤。重点针对安装依赖、内存不足等常见报错提供了具体解决方案,帮助初学者避开陷阱,顺利完成加权基因共表达网络分析。

terraform7cloud的博客 541

38. Count and Say [Easy]

38. Count and Say 38. Count and Say class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ res = '1' ...

qq_35319215的博客 158

IEPE传感器4mA恒流源接口电路

另外传感器的偏置电压大概在10V多点,一般接个电容把直流分量去掉。这里我们要把恒流源的电流设置在4毫安左右,R1取33Ω差不多正好。经过CR的隔直流电路后的波形是这样的。

老白的博客 6118

LeetCode 38 -- Count and Say

LeetCode 38 -- Count and Say The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as

yiayia070614的博客 299

机器学习入门基础 | 基于python的高光谱图像特征挖掘:PCA + 形态学属性处理可视化实战

本文介绍了一种基于PCA和形态学操作的高光谱图像特征提取方法。通过主成分分析降低数据维度,再运用面积开闭操作增强空间结构特征,有效去除噪声并填补孔洞。实验采用WHU-HI-HanChuan数据集,提供完整的Python实现代码,包括数据加载、PCA降维、形态学处理及结果可视化等步骤。该方法能够显著改善图像质量,为后续分类和变化检测任务提供更好的特征输入。实验结果表明,不同阈值的形态学处理能呈现不同程度的空间结构增强效果,对区域生长、分割和聚类等应用具有重要价值。

lestatlu的博客 1048

【C++】构造函数之初始化列表(Initialization list of constructors)

本讲主要是构造函数的初始化列表的讲节,但是本节很重要,可以关乎后面写项目

m0_62599305的博客 2235

LeetCode Notes_#38 Count and Say

LeetCode Notes_#38 Count and SayLeetCode Contents 题目思路和解答题意思路解答总结 题目 The count-and-say sequence is the sequence of integers with the first five terms as following: 1.1 2.11 3.21 4.1211 5...

baji9701的博客 181

2026星宸科技数字IC设计笔试带答案

摘要:本文包含四个计算机科学领域的编程与逻辑设计题目解析。第一部分通过C语言程序补充水仙花数判断代码,考查循环结构和函数设计;第二部分分析Verilog代码的D触发器电路,讨论时序约束与时钟频率影响;第三部分详细讲解静态时序分析中的建立/保持时间计算与违例判断;第四部分计算机体系结构题目涉及CPI、MIPS计算和性能加速比分析。最后还包含一个逻辑代数化简的示例,展示基本的布尔代数简化技巧。这些题目全面覆盖了编程基础、数字电路设计、时序分析和计算机性能评估等核心知识点。(149字)

Open 122

[LeetCode]38. Count and Say

[LeetCode]38. Count and Say题目描述思路字符串拼接,暴力遍历即可代码#include <iostream> #include <string>using namespace std;class Solution { public: string countAndSay(int n) { if (n == 0) return "

Lcharon的博客 482

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

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

LeetCode - 38. Count and Say(36ms)

LeetCode - 38. Count and Say(36ms) The count-and-say sequence is the sequence of integers with the first five terms as following: 1....

dichunpu6524的博客 140

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

leetcode 38. Count and Say

leetcode 38. Count and Say 题目大意:读出每个字符串。譬如说 1 读作 11 11 读作 21 21 读作 1211

编码之路 368

Leetcode题解-38. Count and Say

Leetcode题解-38. Count and Say题目The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as “two

hzw2945的博客 294

LeetCode集锦(十二) - 第38题 Count and Say

LeetCode集锦(十二) - 第38题 Count and Say 问题 The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is ...

weixin_34361881的博客 143

【leetcode 38】Count and Say

虽然是easy难度的题,但是题目确实有些难理解,不瞒大家,结合了百度过后的几篇文章的分析后,才初步清楚了题意,简单分析如下: 1、给定第一个字符串是1; 2、第二个字符串要对前一个字符串分析; 3、如果前一个字符串中有连续相等的n个数字m,则输出nm,不连续则输出1m(例:1的下一个解析结果为11,11的下一个解析结果为21); 清楚了题意之后,开始对题目进行思考,思路如下: 1、对前一...

不了痕的博客 1294

leetcode38. Count and Say

leetcode38. Count and Say

慕鹞 187

leetcode-38. Count and Say

leetcode-38. Count and Say题目: The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, … 1 is read off as “one 1” or 11. 11 is read off as “two

千念飞羽的专栏 332

LeetCode 38. Count and Say

LeetCode 38. Count and Say Solution1:我的答案 【C++】int转换为string的两种方法(to_string、字符串流) 怎么这么慢。。。 class Solution { public: string countAndSay(int n) { string res = &quot;1&quot;; if (n == 1) ret...

Allenlzcoder的博客 253

Leetcode 38 Count and Say

Leetcode 38 Count and Sayclass Solution { public: string sayString(string str) { if(str == "1") return "11"; string result; int len = str.length(); int count = 1; fo

自己的学习笔记 212

LeetCode---38. Count and Say

LeetCode—38. Count and Say 题目 https://leetcode.com/problems/count-and-say/description/ 计数并发言。 n=1,输出1; n=2,上次输出一个1,所以输出11; n=3,上次输出两个1,所以输出21; n=4,上次输出一个2和一个1,所以输出1211; 以此类推 要求给定n,1&lt;=n&lt;=30,输出n对应...

pnnngchg的博客 221
上一篇: 46. Permutations
下一篇: 58. Length of Last Word
云水谣CS
博客等级 码龄9年 8粉丝 268原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值