Codeforces Round #649 (Div. 2)

机器视觉/将HIK海康面阵相机连接Halcon软件 本文简述了如何将海康面阵相机连接到Halcon软件中进行实时取图的过程。 阅读详情

手速思路还是太慢了,放假后要抓紧练习才行

传送门

A. XXXXX

主要思路: 首先求出全部的和是否是x的倍数,如果不是,则输出n, 如果是,那么找前后第一个余数不为0的点即可。

解题思路:
  • 首先我们对所有数求和,如果不是x的倍数,那么直接输出n
  • 然后我们判断是x的倍数的情况,那么我们只要前后找一个位置,这个位置他不是x的倍数即可,然后我们求这个长度的最大值。
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 100010, M = 200010;

int a[N];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n, m;
        scanf("%d%d",&n,&m);
        for (int i = 1; i <= n; i++){
            scanf("%d",&a[i]);
            
        }
        int res = 0;
        int x = n + 1, y = 0;
        for (int i = 1; i <= n; i++){
            if (a[i] % m != 0){
                if (x == n + 1) x = i;
                if (y < i) y = i; 
            }
            res += a[i];
        }
        if (res % m != 0) printf("%d\n",n);
        else{
            if (x != n + 1 && y != 0){
                printf("%d\n",n - min(x,n - y + 1));
            }
            else{
                puts("-1");
            }

        }

    }
    return 0;
}


B. Most socially-distanced subsequence

主要思路:找差值最大的最小数目,找转折点存储即可。

解题思路:
  • 首先我们说明一下为什么找转折点,比如 1 3 5 6 ,他的每个的差值是 2 2 1,而且1 和 6的差值就是5,所以中间过程全部可以忽略掉,因此我们找转折点即可
  • 除了转折点,我们还需要加上首尾的位置,因为无论如何,首尾的位置都会增加当前消费的总和(每个数值都不一样)
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 100010, M = 200010;

int a[N];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n, m;
        scanf("%d%d",&n,&m);
        for (int i = 1; i <= n; i++){
            scanf("%d",&a[i]);
            
        }
        int res = 0;
        int x = n + 1, y = 0;
        for (int i = 1; i <= n; i++){
            if (a[i] % m != 0){
                if (x == n + 1) x = i;
                if (y < i) y = i; 
            }
            res += a[i];
        }
        if (res % m != 0) printf("%d\n",n);
        else{
            if (x != n + 1 && y != 0){
                printf("%d\n",n - min(x,n - y + 1));
            }
            else{
                puts("-1");
            }

        }

    }
    return 0;
}


C. Ehab and Prefix MEXs

主要思路:存储好没有被赋值的位置,然后当当前的值 > 我们最小赋值的值时,我们进行赋值,其他的随便赋值(1e5 + i)

解题思路:
  • 首先我们将每个位置的值都赋为 -1
  • 然后我们开一个stack,存储位置。
  • 然后我们向stack中存入位置(没有被赋值的位置)
  • 当当前值 a[i] > 我们的当前赋值的最小值时,我们进行赋值,然后stack中清除相应位置元素(里面哪一个都可以)
  • 最终我们将没有赋值的位置都赋值成 1e5 + i即可,因为不要相同,而且不要超过1e6
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long ll;

const int N = 100010, M = 200010;

int a[N], res[N];

stack<int> s;

int main(){
    int n;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
    	scanf("%d",&a[i]);
    	res[i] = -1;
    }
    int x = 0;
    for (int i = 1; i <= n; i++){
    	s.push(i);
    	for (int j = x ; j <= a[i] - 1; j ++){
    		int t = s.top();
    		res[t] = j;
    		s.pop();
    	}
    	x = a[i];
    }
    for (int i = 1; i <= n; i++){
    	if (res[i] == -1){
    		printf("%d ",100000 + i);
    	}
    	else{
    		printf("%d ",res[i]);
    	}
    }
    puts("");
    return 0;
}
ROM和RAM在单片机程序运行理解 ROM和RAM是电子设备中两种核心存储组件,主要区别在于:ROM用于长期存储系统程序、用户文件等固定数据,断电后数据不丢失,但写入速度较慢;RAM则用于临时存储运行中的程序和数据,读写速度快但断电后数据会清空。在单片机中,ROM存储程序代码和常量,RAM存储运行时的变量和数据。两者协同工作,ROM如同"永久档案库"保存必要信息,RAM则像"临时工作台"支持高速运算,共同确保设备正常运行。 阅读详情

相关推荐

VirusTotal API密钥获取与Python实战:从注册到自动化威胁分析

在网络安全和自动化运维领域,API(应用程序编程接口)是实现系统间数据交互与功能集成的核心技术。其工作原理是通过预定义的协议和端点,允许程序化访问特定服务的数据与功能。对于安全工程师和威胁分析师而言,API的价值在于能够将手动、重复的安全操作(如文件扫描、情报查询)转化为自动化工作流,从而极大提升威胁检测与响应的效率。一个典型的应用场景是集成第三方威胁情报平台,以实现对可疑文件、URL或哈希值的批量与实时分析。本文聚焦于全球知名的威胁情报服务VirusTotal,详细解析其API密钥的注册流程、安全配置要点

weixin_28707739的博客 428

Codeforces Round #649 (Div. 2)个人题解(A,B,C)

A题: 题意:给你一个数组,找到一个最长数列的和不能被x整除,该数列只能由原数列从第一个开始删除,或者从最后一个开始删除(必须连续删除)。 思路:直接设一个前缀和数组,循环一遍判断最大值就行了。如果全部元素都能被x整除,那就直接输出-1。 #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #define MAX 1000

weixin_43425598的博客 259

【Excel VBA 编程】表格内自动生成进度条

在表格中生成进度条,进度条需要自适应单元格的宽度,根据不同进度区间变换颜色,并且按照进度数据大小显示其长短

wei1019的专栏 1525

Codeforces Round #649 (Div. 2) C (思维)

链接 题意 已知长度为n的非递减数组a,构造出长度相同的数组 b,使得对于每个 i,b1, b2, … , bi 中未出现的最小非负整数为 ai 。 思路 得发现这个结论:当**a[i]!=a[i-1]**时 ,b[i] = a[i - 1] 代码 //过题代码 #include<bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n,a[N],aa[N],ans[N],minn = 0; int main(

weixin_45767800的博客 179

SPI模式下的SD卡读写,为什么你的数据总出错?详解时序与状态机避坑指南

本文深入探讨SPI模式下SD卡读写数据出错的根本原因,提供时序优化与状态机设计的实战指南。针对时钟周期计数、状态机跳转和忙检测等核心问题,详解命令时序细节、状态机同步策略及高级避坑技巧,帮助开发者提升SD卡在SPI模式下的稳定性和性能。

weixin_30514745的博客 267

从零到英雄:如何用FPGA和AD9288打造你的第一台便携式示波器

本文详细介绍了如何利用FPGA和AD9288 ADC芯片从零开始打造一台高性能便携式示波器。通过硬件架构设计、高速数据采集系统实现及信号处理与显示系统的开发,读者可以掌握400Msps采样率的实现方法,并了解关键器件选型与系统优化技巧。

jjj34的博客 282

Codeforces Round #649 (Div. 2)ABC题解

A. XXXXX 题目链接:A. XXXXX 题意:找出数组a[ ]的最大子数组,且这个子数组只能从开头删除几个(可能是零或全部)元素或者从结尾删除几个(可能是零或全部)元素。,使得子数组不可被x整除。 题解**:我们可以知道如果一个数可以被x整除,那么减去一个不可被x整除的数字后这个数字就不能被x整除了。** 这里有三种情况:1.a[ ]数组总和不能被x整除,答案为n; 2.a[ ]数组总和不可被x整除且数组中存在不可被x整除的数,答案为n减去包括这个数的最小个元素,即n-min(i,n-1+1)(i为这

m0_46122129的博客 464

思科模拟器汉化教程(附带中文汉化包)

思科模拟器是一种模拟Cisco网络设备的软件工具。它可以模拟Cisco网络设备的所有功能,包括路由器、交换机、防火墙等,并提供了一个可视化的用户界面,让用户可以通过图形化的方式来管理网络设备。思科模拟器因其便捷、易用的特点被广泛应用于网络工程师的实验、测试和培训等方面思科模拟器的功能是强大的,但当我们在使用思科模拟器的时候就会有一些烦恼,由于思科是全球最大的企业级网络设备供应商之一。思科公司的产品和服务被广泛应用于各种领域和行业,所以思科模拟器默认是全英文的,但是在最新版本中是支持中文的。

2302_76908369的博客 4万+

Codeforces Round #649 (Div. 2) C. Ehab and Prefix MEXs

Codeforces Round #649 (Div. 2) C. Ehab and Prefix MEXs 题目链接 Given an array a of length n, find another array, b, of length n such that: for each i (1≤i≤n) MEX({b1, b2, …, bi})=ai. The MEX of a set of integers is the smallest non-negative integer that doe

旺崽的博客 2609

某音私信接口二进制解析

本文探讨了某音私信接口的二进制请求处理过程,重点分析了请求体中的非文本字符和混合编码结构。文章详细描述了编码过程,包括使用Protocol Buffers的序列化方法将结构化数据转换为字节流,并通过Uint8Array包装成二进制数组。作者展示了如何提取和补全s.encode方法,并将其转化为Base64字符串以便在Python中解码执行

码王吴彦祖的博客 906

32GB Jetson Orin SOM 不能刷机问题排查

拿到了一个新的Orin SOM,当用orin Devkit CVB或定制的CVB不能用Linux_For_Tegra刷机,flash日志(JetPack5.0DP和5.0.1DP都失败了) 2. 确认mb2配置中将CVB的eeprom读取大小设置是否为0 ? 已经确认是正常的 在定制的orin cvb flash上使用Orin devkit som,启动是成功的。但新得到的Orin som并不工作可以排除理由:使用Orin Devkit CVB和Orin SOM(不是Devkit SOM)仍然不能

jzwjzw19900922的博客 1499

Codeforces Round #649 (Div. 2) B. Most socially-distanced subsequence

Codeforces Round #649 (Div. 2) B. Most socially-distanced subsequence 题目链接 Given a permutation p of length n, find its subsequence s1, s2, …, sk of length at least 2 such that: |s1−s2|+|s2−s3|+…+|sk−1−sk| is as big as possible over all subsequences of p wi

旺崽的博客 2566

YOLO11改进-注意力-引入级联组注意力机制(Cascaded Group Attention, CGA)

输入特征拆分:输入特征进入 CGA 模块后,被均匀拆分为个部分,每个部分作为一个注意力头的输入,这样每个头关注输入特征的不同部分,实现特征的并行处理,同时为提高注意力多样性奠定基础。注意力头计算单元:每个注意力头包含三个线性投影层、、用于将输入特征映射到不同子空间,以及计算自注意力的单元。在计算过程中,通过注意力头之间的级联操作,前一个头的输出会累加到下一个头的输入上,实现特征的逐步细化。

qq_64693987的博客 2492

Codeforces Round #649 (Div. 2) Jun/13/2020 23:05UTC+8

Codeforces Round #649 Div. 2 Jun/13/2020 23:05UTC+8A. XXXXXB. Most socially-distanced subsequenceC. Ehab and Prefix MEXs(构造) 比赛链接 https://codeforces.com/contest/1364 比赛记录 https://blog.csdn.net/cheng__yu_/article/details/105395197 A. XXXXX 题意:给定一个长度为 n 的数组

qq_17080419的博客 2407

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

IEM模型,地表粗糙度模拟

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

Codeforces Round #649 (Div. 2)A

(A)题目:给出一长度为n的数组和一个数据hate,求出数组的子数组中不能整除hate的最长子数组 ①我的想法:暴力遍历,找出数组中的所有子数组,输出子数组的最大长度 #include<stdio.h> #define x 100000 int judge(int string[],int y,int length,int hate){ //judge能找出所有的string数组的长度为y int time=length-y+1; .

weixin_45758110的博客 270

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Codeforces Round #649 (Div. 2) A~C题解

A. XXXXX B. Most socially-distanced subsequence C. Ehab and Prefix MEXs

SarenSage的博客 960

SAP B1中文培訓教材_SDK

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

Codeforces Round #649 (Div. 2) D

题意: 给一个无向图,不含重边和自环,现在给出一个整数 kkk ,现在有两个问题: 在图中找到大小为 ⌈k2⌉\lceil \frac{k}{2} \rceil⌈2k​⌉ 的独立点集; 在图中找到长度不超过 kkk 的环; 其中独立点集即集合中任意两点之间没有边;给出的无向图至少满足上面两种情况之一,现在要求你解决其中一个问题(自选),并输出具体答案,问题 111 输出独立点集,问题 222 按顺序输出环; 分析: dfsdfsdfs 的同时用递归深度做权值判断每个环的大小,找到符合问题 222 的环就

Joker & Liar的博客 267

Codeforces Round #649 (Div.2) Solution

...

curry的博客 399

Codeforces Round #649 (Div. 2)。A。

题意t种情况,数组a的长度为n,然后数组的和不能被n整除,问a的长度,可以从前或者后面进行计算。 题解:两个思路:1.使用双指针,代码如下: #include <iostream> #include <algorithm> using namespace std; const int maxn = 1e5 + 10; int main(){ int a[maxn],b[maxn]; int t,x,n; cin>>t; while(t--){ int

m0_47943920的博客 217

Codeforces Round #649 (Div.2)题解

文章目录A - XXXXXB - Most socially-distanced subsequenceC - Ehab and Prefix MEXs A - XXXXX 题意:这个题让你找从开头或者是结尾去掉最少几个数以后总和是不能整除给定的x 思路:如果这个序列总和可以整除给定的x的话,那么我们只要找到一个数可以不被x整除,把他从序列中取出,那么序列中剩余的总和也就不能被整除了。 分别从前从后开始搜索即可: /*Keep on going Never give up*/ #pragma GCC opt

xxxxxiao123的博客 3067

Codeforces Round 刷题计划 #649 (Div. 2)

题目 A 1.题目描述: 2.题意: 找出最长的一段序列,使得序列的和不被x整除。 3.思路: 思维。 如果数皆为x的倍数,那么直接输出-1;如果全部数加起来取模x不等于0,那么输出n;否则,考虑去掉前面第一个模x非零的数的下标和n-最后一个模x非零的数的下标的最小值。【假设模x后序列是:0001000020000300004000500,如果加起来模x为0,那么显然把5去掉就最长】 4.代码: //A //#include<bits/stdc++.h> //#pragma GCC optim

weixin_46175963的博客 304

[Codeforces Round #649 (Div. 2)]1364

文章目录A - XXXXX [思维]B - Sign Flipping [思维]C - Sign Flipping [思维] A - XXXXX [思维] 目录 题目传送门 题意 有 nnn 个数的数组 a[]a[]a[],要使数组的总和%k!=0\% k != 0%k!=0 可以选择删去开始的连续几个数或者删去末尾的连续几个数 问这个数组满足条件的最长长度,不存在则输出 −1-1−1 分析 只要找到头尾最近的一个 %k!=0\% k != 0%k!=0 的数,然后扣掉这一整段的长度 Code #i..

QAQ! 的博客 393

Codeforces Round #649 (Div. 2) 部分题解

比赛链接 文章目录A. XXXXXB. Most socially-distanced subsequenceC. Ehab and Prefix MEXs A. XXXXX 大致题意: 给你一大小为 nnn 的数组,要求最长的连续的且和不能被x整除子数组,无法中找到输出 -1 。 解题报告: 先考虑 -1 的情况:每一位都能被 x 整除 在考虑 n 的情况:所有元素之和不能被 x 整除 其他情况: 左右指针同时开始遍历,很明显当前位为 0 对和没有影响,因此要删除一位不为 0 的数即可,最后取一个最大长度

qhq889的博客 486

Codeforces Round #649 (Div. 2) A-D

A:如果sm是k的倍数,肯定左右删最少的数。删到不是k的倍数的数即可 #include <bits/stdc++.h> using namespace std; typedef long long ll; #define ls (o<<1) #define rs (o<<1|1) #define pb push_back const double PI= acos(-1.0); const int M = 1e5+7; /* int head[M],cnt; void

bjfu170203101的博客 352

Codeforces Round #649 (Div. 2) / contest 1364

目录A XXXXXB Most socially-distanced subsequenceC Ehab and Prefix MEXsD Ehab's Last CorollaryE X-OR A B C D E √ √ √ ○ ○ ( √:做出; ●:尝试未做出; ○:已补题 ) 题目地址:https://codeforces.com/contest/1364 这一次做得好差…… ????(ಠ_ಠ) A XXXXX 题意:给出一个数组 a,一个整数 x,求最长的 a 的子数组

dragonylee的博客 391

Codeforces Round #649 (Div. 2) ABC题解

A. XXXXX **题目链接** 题意:找出数组a[]的最大子数组,只能从开头删除或结尾删除一定的元素。使得子数组和不可被x整除。 题解:分类删除便可,记录和和数组长度。 #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <string> #include <cmath> #define ll long long

Think_kill的博客 572
上一篇: Educational Codeforces Round 89 (Rated for Div. 2)
下一篇: Codeforces Round #651 (Div. 2)
清泠,
博客等级 码龄8年 16粉丝 184原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值