Codeforces Round #407 div2 题解【ABCDE】

Anastasia and pebbles

题意:你有两种框,每个框可以最多装k重量的物品,但是你每个框不能装不一样的物品。现在地面上有n个物品,问你最少多少次,可以把这n个物品全部装回去。

题解:其实就是问你得用多少次框,然后把多少次除以2就好了。每次装k的物品装回去就好了。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
int a[maxn],n,k;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    long long ans = 0;
    for(int i=1;i<=n;i++){
        ans+=(a[i]+k-1)/k;
    }
    cout<<(ans+1)/2LL<<endl;
}

Masha and geometric depression

题意:给你一个b1,q,再给你一个l,m,和m个数a[i]。然后你需要把不等于a[i],且小于等于l的数记录下来。

题解:直接暴力就好了,因为等比数列跑得特别快,如果要超过l的话,会很快的超过l了,而且如果答案有限的话,显然不会超过200?所以直接暴力吧。

代码:

#include<bits/stdc++.h>
using namespace std;

set<long long> S;
long long b,q,l,m;
map<long long,int>H;
int main(){
    cin>>b>>q>>l>>m;
    for(int i=0;i<m;i++){
        long long k;
        cin>>k;
        S.insert(k);
    }
    int time = 0;
    int ans = 0;
    long long now = b;
    while(time<500000){
        time++;
        if(abs(now)>l)break;
        if(S.find(now)==S.end()){
            ans++;
        }
        now=now*q;
    }
    if(ans>30000){
        cout<<"inf"<<endl;
    }else{
        cout<<ans<<endl;
    }
}

Functions again

题意:定义f(l,r)=sigma(abs(a[i]-a[i+1)*(-1)^(i-l)),给你n个数,找到最大的f(l,r)

题解:跑一个前缀和,然后你要奇数位置开头的,那么就正常做。如果是偶数位置开始的话,那么就乘上一个-1就好了嘛。掏个set算前缀的最小值和最大值。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
long long a[maxn],b[maxn],c[maxn];
int n;
set<long long>A,B;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(n==2){
        cout<<abs(a[1]-a[2])<<endl;
        return 0;
    }
    for(int i=1;i<n;i++){
        b[i]=abs(a[i]-a[i+1]);
        if(i%2==1)c[i]=c[i-1]+b[i];
        else c[i]=c[i-1]-b[i];
    }
    A.insert(c[1]);
    B.insert(c[2]);
    long long ans = max(c[1],c[2]);
    ans=max(ans,abs(a[2]-a[3]));
    for(int i=3;i<n;i++){
        ans=max(ans,c[i]);
        ans=max(ans,c[i]-*B.begin());
        ans=max(ans,c[i]-*--B.end());
        ans=max(ans,-(c[i]-*A.begin()));
        ans=max(ans,-(c[i]-*--A.end()));
        if(i%2==1)A.insert(c[i]);
        else B.insert(c[i]);
    }
    cout<<ans<<endl;
}

D. Weird journey

题意: 给你一个图,这个图有自环,现在问你有多少个路径满足可以经过m-2条边两次,剩下两条边一次。

题解:答案为 自环与自环相组合,自环和其他边组合,其他边和其他边组合。其中其他边和其他边组合的时候,必须要挨在一起。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;
int n,m;
vector<int>E[maxn];
int Cnt,flag[maxn],vis[maxn],d[maxn];
void dfs(int x){
    vis[x]=1;
    for(int i=0;i<E[x].size();i++){
        Cnt++;
        if(E[x][i]==0){
            Cnt++;
            continue;
        }
        if(vis[E[x][i]])continue;
        dfs(E[x][i]);
    }
}
int main(){
    scanf("%d%d",&n,&m);
    int st = 1,cnt = 0,cnt2 = 0;
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if(a==b){
            cnt ++;
            flag[a]++;
            E[a].push_back(0);
            E[0].push_back(a);
        }else{
            st=a;
            cnt2++;
            d[a]++;d[b]++;
            E[a].push_back(b);
            E[b].push_back(a);
        }
    }
    dfs(st);
    if(Cnt!=m*2){
        cout<<"0"<<endl;
        return 0;
    }
    long long ans = 0;
    ans=ans+1ll*cnt*cnt2;
    ans=ans+1ll*cnt*(cnt-1)/2;
    for(int i=1;i<=n;i++){
        ans=ans+1ll*d[i]*(d[i]-1)/2;
    }
    cout<<ans<<endl;
}

E. The Great Mixing

题意:现在有k个物品xi/1000,你现在可以任意挑选,并随便使用,你需要调制出n/1000的物品,问你最少使用多少个。

题解:首先去重,那么k最多只有1001了。然后我们让所有的xi减去n,然后就可以理解为凑0了,然后就可以跑完全背包。第一维的个数最多1000个,第二维的范围就是[-1000,1000]。

代码:

#include<bits/stdc++.h>
using namespace std;
int n,k;
const int maxn = 1e6+7;
int a[maxn];
vector<int>v;
map<int,int> dp[2003];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++){
        scanf("%d",&a[i]);
        a[i]-=n;
        v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    dp[0][0]=1;
    map<int,int>::iterator it;
    for(int i=1;i<=1002;i++){
        for(it=dp[i-1].begin();it!=dp[i-1].end();it++){
            for(int j=0;j<v.size();j++){
                if(abs(it->first+v[j])>1000)continue;
                dp[i][it->first+v[j]]=1;
            }
        }
        if(dp[i].count(0)){
            printf("%d\n",i);
            return 0;
        }
    }
    printf("-1\n");
    //ax+by+...+t=n*1000(a+b+c+..+);
}
【图像超分】论文精读:RepSR: Training Efficient VGG-style Super-Resolution Networks with Structural Re-Paramete 摘要: 本文提出RepSR,一种基于结构重新参数化和批量归一化(BN)的高效VGG式超分辨率网络。针对SR任务中BN易引发伪影的问题,作者通过分析发现训练-测试阶段的不一致性是主因,并提出先使用小批量统计训练、后期切换为总体统计的优化策略。RepSR块设计包含干净的残差路径和带改进BN的扩展-压缩卷积路径,有效平衡了训练非线性与推理效率。实验表明,RepSR在不同模型规模下优于现有重参数化方法,且实际推理速度更快。该工作为SR提供了性能与效率兼优的解决方案,相关代码未开源。 关键词: 超分辨率、结构重参数化 阅读详情

相关推荐

创新实训项目博客:基于LoRA的医疗大模型高效微调实战

预训练大语言模型(LLMs)虽然具备了广泛的知识和一定的通用能力,但在特定领域(如医疗)或特定任务(如遵循特定指令格式进行思考链推理)上,其表现往往不尽如人意。微调(Fine-tuning)能够使模型学习到特定领域的数据分布和任务模式,从而在目标任务上获得更好的性能,使其更贴合实际应用需求。使用Unsloth框架加载并以4-bit量化模型。基于数据集,构建了包含明确思考链引导的训练Prompt。配置了LoRA参数,并使用SFTTrainer在单张T4 GPU上对模型进行了高效微调。

m0_73556916的博客 1293

Codeforces Round #407 (Div. 1) 题解

A: 给定长度为nn的数组aa,定义函数ff,对于∀1≤l<r≤n\forall 1\leq l < r \leq n 有f(l,r)=∑r−1i=l|a[i]−a[i+1]|⋅(−1)i−lf(l,r) =\sum_{i=l}^{r-1} |a[i] - a[i + 1]| \cdot(-1)^{i - l} 求所有ff函数中的最大值 2≤n≤105,|ai|≤1092 \

CRZbulabula的博客 740

ESP32-S3开发环境避坑指南:VS Code+ESP-IDF离线安装全流程(附国内镜像加速)

本文提供了一份详细的ESP32-S3开发环境离线安装指南,重点解决网络依赖问题。通过整合国内镜像加速,手把手教你完成VS Code、ESP-IDF框架、工具链及Python依赖的本地化部署,实现稳定、可重复的开发环境搭建,大幅提升IoT开发效率。

peach的博客 968

Codeforces Round #407 (Div. 2)(A,B)

A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in

neversayno_yl的博客 350

(数字ic验证)从零开始的apb_watchdog验证模块搭建(一、功能介绍与环境搭建)

apb_watchdog验证模块搭建(一)文章目录 文章目录apb_watchdog验证模块搭建(一)文章目录前言一、apb_watchdog简单功能介绍二、测试平台环境搭建1.测试所用模板介绍2.tb与interface2.env与watchdog_pkg3.test与base_sequence4.Makefile总结——当前验证结构 前言 本文介绍了apb_watchdog验证模块的搭建过程与其具体代码,主要包括其中验证环境的构建,测试序列的发送与回归测试收集。主要运用systemvorilog与u

peop1e的博客 9749

无源定位之时差估计的精确时差估计算法(ETDE)及MATLAB实现程序

时差估计算法之精确时差估计(ETDE)欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想

伊谢尔伦的林中小路 4261

Codeforces Round #407 (Div. 1)

人傻不会B 写了C正解结果因为数组开小最后RE了 疯狂掉分 AC:A Rank:392 Rating: 2191-92->2099 A. Functions again 题目大意:给定一个长度为n的数组,求最大的,其中1<=l<r<=n。(n<=10^5) 思路:按左端点所在位置的奇偶性分开计算即可。 #include<cstdio> ...

weixin_30237281的博客 135

基于springboot医院医疗仪器管理系统

基于Spring Boot的医院医疗仪器管理系统是一款专门为医院设计的高效管理工具。

2201_75927219的博客 1016

codeforces Codeforces Round #407 Div2题解 B,C,D,E

题目链接:about:http://codeforces.com/contest/789B仔细想一想,对于一个l r 区间的最大值,其实就是求一个最大连续子序列。不过这个地方有点特殊,区间都是以开头为正数的。然后正负正负。但仔细想想就会发现其实就只有两种情况:对于这整个差的绝对值得序列:1.正负正负…….2.负正负正……所以我们构造这样的两个序列,求这两个序列的最大子序列。 . Masha a

now_ing的博客 293

【无人机基站】基于K-mean算法实现无人机基站部署附matlab代码

【无人机基站】基于K-mean算法实现无人机基站部署附matlab代码

天天酷科研的博客 251

2025华为od机试真题B卷【版本管理】JavaScript实现

在 软件版本管理中,版本号由点分割的数字组成,例如 1.2.3 和 2.8。现在,你需要编写一个函数,计算两个版本号之间的可用版本号个数。这里的可用版本号指的是所有满足 version1<x<version2的版本号x的个数。若 version1 >=version2 返回0.,

MISAYAONE的博客 260

Codeforces Round #407 (Div. 2) ABCD

Codeforces Round #407 (Div. 2) ABCD

WinForBest 616

Qt界面美化-飞扬青云自绘控件插件的使用-避免采坑

1、先上一个集成到QtCreater中的效果图: 2、飞扬青云自绘控件插件下载地址:https://gitcode.net/mirrors/feiyangqingyun/qucsdk?utm_source=csdn_github_accelerator 3、集成插件到QtCreater中的方法: (1)、查看自己使用的QtCreater的版本信息,我的:Qt 5.15.2 MSVC2019 64位 (2)插件下载下来后工程预览: 我选择msvc版本的SDK,打开找到匹配的SDK:...

小米的修行之路 2799

codeforces Codeforces Round #407 Div2题解

5A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a wal

blood_in_the_sky的专栏 580

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Codeforces Round #407 (Div. 2) 解题报告

Problem A-Anastasia and pebbles 简单贪心//Author: Lixiang #include<stdio.h> #include<algorithm> using namespace std; const int maxn=100001; int floordiv(double a,double b){ return (int)a/b; } struct P

理想之国 465

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Codeforces Round #407 (Div. 2)解题报告

A:Anastasia and pebbles 水题。。直接按题意搞一下就行了 B:Masha and geometric depression 同样是一个模拟题,map记录bad数,特判q=-1和q=1的情况即可 C:Functions again ……好像说是最大子段和? 看别人题解代码很长的样子  我是记录前缀和的最大最小值,贪心一下就行了,因为正负对最大最小值的影响其实是没有的

来自Fop_zz的辣鸡题解或教程 378

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces 788 C. The Great Mixing

题目链接:http://codeforces.com/contest/788/problem/C   一看就不能暴力$DP$,我们可以将浓度的合并操看作为在追逐一高度,每次操作前这个高度都会向上走$n$,每次加入一定浓度的汽水就增加了相应的高度$a_i$,由于每次都是进行相同的转移,所以一旦高度差的绝对值大于了$1000$,这个状态就没有了意义(因为一定会有等价的状态比他更好),剪枝一...

weixin_30724853的博客 294

Codeforces Contest 788 problem C The Great Mixing —— 求一些无穷个数之和为0所需最少数

This way 题意; 给你n个数,每个数都有无穷多个,让你拿一些数使得这些数之和/数的个数=x 题解: a1+a2+..+akk=x\dfrac{a1+a2+..+ak}{k}=xka1+a2+..+ak​=x =&gt;a1+a2+..+ak=x∗k=&gt;a1+a2+..+ak=x*k=>a1+a2+..+ak=x∗k =&gt;(a1−x)+(a2−x)+...

天翼之城的博客 224

BFS (图)——Codeforces 788 C. The Great Mixing

题目 **The Great Mixing** Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration . To...

点滴 687

笔试强训(11,21)删除公共字符、链表公共结点、mari和shiny

本文总结三道牛客算法题:1)删除公共字符——用布尔数组标记需删字符,实现O(n+m)时间复杂度;2)两个链表首个公共结点——双指针“走完换头”法,简洁高效;3)mari和shiny——通过三个计数器动态统计“shy”子序列,一次遍历完成。三题均优化至最优时空复杂度,涵盖哈希标记、双指针技巧与子序列计数的动态思想,代码可直接提交。

2401_87882972的博客 489

算法竞赛所需数据结构(1)单调栈与单调队列

本文系统讲解单调栈的核心概念与应用,强调其在算法中的重要性。通过构造单调递增或递减栈,可高效解决“寻找左右最近更大/更小元素”四类问题,核心思想为:正序找左、逆序找右,大则递减、小则递增。文章附带模板代码及经典例题“发射站”(洛谷P1901),展示如何将模板灵活迁移至实际问题,实现O(N)时间复杂度的优化解法。作者呼吁夯实基础,积小成大,持续练习,提升算法能力。

Fcy648的博客 231

字符串哈希被卡?双哈希、溢出与随机 base 的取舍

本文剖析单哈希易被构造碰撞的原理,对比双哈希在安全性与效率上的权衡,强调模数选大质数、base随机且小于模数的重要性。指出仅用于相等判断时可用哈希,涉及字典序或统计则应优先后缀数组、SAM或Z函数。提出对拍验证必要性,并建议按题型归档参数组合以提升复用性与准确性。

2401_85062569的博客 391

QCHEM-01-ADAPT-SC-VQE:自校正拟设的变分量子本征求解器用于分子基态计算完整技术指南(下部分)

本文为 DREAMVFIA QCHEM-01-ADAPT-SC-VQE 量子分子基态计算引擎(下部分),完整交付 515 行零黑盒依赖 Python 生产级源码与 5 项全通过自检日志(H2 误差 0.000000 mHa、LiH 势能面误差 0.00177 mHa、CNOT 深度压缩 75.0%-89.3%、QNG 相对 Adam 提速 6.75x、对称性验证叠加二次 ZNE 抑制噪声 265.6x 至 0.245 mHa),附三大工业落地场景与 YAML 配置。

梦帮科技开源中心 397

【数据结构-11】设计循环队列

我i们知道,对于普通(顺序)队列而言(底层是数组这种类型),当队尾走到size-1的位置,该队列就被判定为队满,不能再插入数据,即使前面由于出队空出了一些位置。这个现象叫做假溢出。(底层是链表实现的队列不存在逻辑上的队满,因为入队操作直接在ptail指针后面malloc增加节点即可,而数组队列容量预先固定,存在逻辑上的队满。循环队列是将底层的数组设计成逻辑上的环形(循环队列我们更推荐使用数组来实现,后面探讨。),当队尾下标走到size-1的位置,下一步它会回到下标为0的位置。

a bit 191

java程序设计笔记

同理,包装类比较必须用 equals 而非 ==——Integer 在 -128 到 127 之间会复用缓存对象,超出范围则不会,== 的结果完全不可靠。多数教材把 final 等同于常量,但它在对象引用上的含义更值得注意:final 修饰引用变量时,锁定的是引用本身,而非对象内容。LinkedList 底层是双向链表,随机访问 O(n),头尾操作 O(1)。通过对象引用调用静态方法(person.staticMethod())在语法上合法,但编译器实际解析的是类名,徒增解析成本。

Linnn_0705的博客 192

【算法拾光】BFS 最短路径|单词接龙 为高尔夫比赛砍树

本文分析了力扣两道BFS经典题:单词接龙与砍树。前者将单词视为图节点,通过改变一个字母生成新词,用哈希集去重,BFS求最短变换序列;后者按树高排序砍树顺序,分段BFS求网格中相邻点最短路径,用二维vis数组防重复访问。共性为无权图最短路径天然适合BFS;区别在于前者动态生成邻接点,后者需预排序并多次调用BFS。

wuqingyigexiaoba的博客 328
上一篇: 如何绑定腾讯云的域名到godaddy的站点
下一篇: 钉钉携手氚云引爆业界合作 集成能力如虎添翼
weixin_34290000
博客等级 码龄11年 4799粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值