CodeForces - 716B Complete the Word( 暴力 )

嘉立创EDA报错:元件引脚与焊盘未对应报错解决记录 原件引脚与焊盘未对应报错解决方法,一文总结! 阅读详情
题目链接:点击进入
题目

在这里插入图片描述
在这里插入图片描述

题意

若 s 存在长度为 26 且 26 个大写英文字母都各出现一次的连续子串 t ,就认为是好的。
现在给你一个带 ?的 s ,问能不能通过把所有 ?变成大写英文字母让 s 变成好的,不能输出 -1 ,能输出变化后的 s

思路

暴力判断 s 长度为 26 的连续子串中每个字母是不是只出现一次 ( 不算 ‘ ? ’ ),若是就是该这个子串,剩下的 ‘ ? ’ 随便填。若不存在就 -1。

代码
// Problem: Complete the Word
// Contest: Virtual Judge - CodeForces
// URL: https://vjudge.net/problem/CodeForces-716B
// Memory Limit: 262 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//#pragma GCC optimize(3)//O3
//#pragma GCC optimize(2)//O2
#include<iostream>
#include<string>
#include<map>
#include<set>
//#include<unordered_map>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<fstream>
#define X first
#define Y second
#define base 233 
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define lowbit(x) x & -x
#define inf 0x3f3f3f3f
//#define int long long
//#define double long double
//#define rep(i,x,y) for(register int i = x; i <= y;++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double pai=acos(-1.0);
const int maxn=1e6+10;
const int mod=1e9+7;
const double eps=1e-9;
const int N=5e3+10;
/*--------------------------------------------*/
inline int read()
{
    int k = 0, f = 1 ;
    char c = getchar() ;
    while(!isdigit(c)){if(c == '-') f = -1 ;c = getchar() ;}
    while(isdigit(c)) k = (k << 1) + (k << 3) + c - 48 ,c = getchar() ;
    return k * f ;
}
/*--------------------------------------------*/

string s;
int cnt[30];

int main() 
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	cin>>s;
	int len=s.size(),pos=-1;
	for(int i=0;i<len;i++)
	{
		if(i+26-1>=len) break;
		for(int j=0;j<26;j++) cnt[j]=0;
		int flag=0;
		for(int j=i;j<=i+26-1;j++)
		{
			if(s[j]=='?') continue;
			cnt[s[j]-'A']++;
			if(cnt[s[j]-'A']>1)
			{
				flag=1;
				break;
			}
		}
		if(!flag)
		{
			pos=i;
			break;
		}
	}
	if(pos==-1) cout<<-1<<endl;
	else
	{
		for(int i=pos;i<=pos+26-1;i++)
		{
			if(s[i]=='?')
			{
				for(int j=0;j<26;j++)
				{
					if(cnt[j]==0)
					{
						cnt[j]++;
						s[i]=(char)(j+'A');
						break;
					}
				}
			}
		}
		for(int i=0;i<len;i++)
			if(s[i]=='?')
				s[i]='A';
		cout<<s<<endl;
	}
    return 0;
} 
GEE案例教程:融合Sentinel-1 SAR数据、Sentinel-2光学影像和WorldPop人口数据,构建完整的洪水监测与影响评估工作流 本文介绍了一个专为巴基斯坦哈扎拉分区设计的洪水监测系统,该系统整合了Sentinel-1 SAR数据、Sentinel-2光学影像和WorldPop人口数据等多源遥感数据。系统通过VV极化SAR数据的水体提取算法(阈值-13dB)实现洪水范围监测,结合10米分辨率的光学影像进行可视化验证,并利用100米分辨率人口数据评估受灾人口。系统提供完整的技术实现,包括研究区加载、遥感数据处理、日期选择界面和洪水变化检测等功能模块,为灾害应急响应提供科学依据。 阅读详情

相关推荐

国密SKF库数字签名全解析:SM2签名与验证的详细实现

本文详细解析了基于国密SKF库实现SM2数字签名与验证的全过程。内容涵盖SKF库环境搭建、设备初始化、PIN码验证、SM2签名生成以及纯软件与SKF库两种验证方式的详细实现,为开发者提供了一份实用的国密算法开发指南。

weixin_29303701的博客 323

Complete the Word CodeForces - 716B暴力模拟

思路:细节比较多。 1.不一定是26一循环,只要字符串中有超过两个的字母,就要重新开始统计。 ac代码: #include<cstdio> #include<map> #include<iostream> #include<cstring> using namespace std; char s[500005]; int vis[100]; stri...

weixin_43960370的博客 497

C# 进程间 双内存共享 高帧率图像传输

演示了两个进程之间通过 双内存共享 的方式, 来实时处理图像,并以高帧率(40~60FPS)传输的基本示例。 进程间内存共享的优点:高性能、低延迟、资源效率高、简单可靠。 适用场景:实时图像处理、大数据传输、多进程协作、实时监控系统,等等。

qianqiansd 1996

【CodeForces】716B - Complete the Word(暴力)

点击打开题目 B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder loves to re

wyg1997 1906

SAP ABAP开发避坑:BAPI_MATVAL_PRICE_CHANGE调用报‘估价未维护’的完整解决流程

本文深入解析SAP ABAP开发中调用BAPI_MATVAL_PRICE_CHANGE函数时遇到的'估价未维护'错误,提供从基础配置检查到CKML_PRICE_SEND表维护的完整解决方案。通过实战案例和代码示例,帮助开发者快速定位问题并实现批量价格更新的自动化处理,提升开发效率。

weixin_28705087的博客 427

S32K344开发环境搭建全攻略:S32DS 3.5.12与RTD 3.0.0实战指南

在嵌入式开发中,集成开发环境(IDE)与实时驱动(RTD)的协同配置是项目启动的关键。S32DS作为NXP官方IDE,结合RTD包,为S32K3系列提供底层驱动支持。正确安装与路径配置能确保编译、调试与烧录流程顺畅,避免常见错误。该环境适用于汽车电子、工业控制等场景,如车身域控、BMS。本文基于S32K344芯片,详细记录从软件下载到调试的完整过程,帮助开发者快速搭建稳定开发环境。

weixin_42713608的博客 211

CodeForces - 716B Complete the Word(暴力)

ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears ex...

ling_wang的博客 321

Untiy之如何实现AI+MR (Pico4u 相机推流MR画面给Server做实时AI图像识别)

本文介绍了基于Pico4U企业版开发AI+MR应用的实现方案。文章详细说明了硬件准备步骤,包括购买企业版设备、申请相机权限和注册管理平台。重点讲解了Unity开发中获取摄像头画面的两种技术方案:通过Overlay直接渲染到Android Surface,或使用API获取图像数据转换为Texture。提供了完整的代码示例和权限配置说明,并揭示了底层通过JNI调用Android原生API的技术原理。该方案适用于带电操作等实习场景,可提升安全性和学习趣味性。

TxNet 1339

Codeforces 716 B. Complete the Word(暴力)——Codeforces Round #372 (Div. 2)

传送门B. Complete the Word time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output ZS the Coder loves to read the dictionary. He thinks that a word is nic

代码改变世界 806

手把手教你学SOC芯片架构--NoC(片上网络,Network on Chip)全方位解析

​、​。

MHD0815的博客 863

Winform从入门到精通(38)——StatusStrip(史上最全)

本文介绍StatusStrip控件的详细用法,包含所有属性和事件,绝对史上最全!

qq_34059233的博客 2758

【Codeforces】716B Complete the Word (26个字母)

http://codeforces.com/contest/716/problem/B 给你一个字符串该字符串中是否存在长度为26且这26个字母没有重复 一个满足上述条件但是部分区域是问号的话,需要用剩下的字母覆盖掉问号,其余部分的问号可以随便赋值 没有的话输出-1 暴力即可。 #include &lt;iostream&gt; #include &lt;string&gt; #inc...

( :3 ) 288

LVGL core group焦点分组管理(lv_group.c)

lv_group_t是用于焦点管理的,将需要获取焦点的对像加入到同一个分组内,再将其通过挂到指定的事件驱动中,就可以控制焦点了。而被加入的对象又可以通过焦点状态事件和事件来控制对象的焦点逻辑了。创建好的分组通过接口挂事件驱动中,这样就可以指定一个自定义的焦点分组了。;) {if(!} }友情提示:无论是接口还是都是单例的,即被设置后前一个被设置的值就失效了;此方案可以保证焦点的唯一 性,但也一定要记住要在适合的位置设置回来,以防丢失焦点。

Bigan(安)的博客 3907

codeforces 372 div2 Complete the Word 716B

大概有三次的CF没有补了,国庆后,慢慢开始 这个题目,异常之暴力,我自己都觉得代码写的不优美....但是实在只是一个暴力,随便写写就好 遍历数组,每一位枚举26个,判断问号数量或者重复数量.... #include <stdio.h> #include <string> #include <iostream> #include <...

109

计算机控制技术及应用

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

假人有限元模型

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

Codeforces 716B Complete the Word

题目链接:http://codeforces.com/problemset/problem/716/B 题意:给一个字符串,问你这个字符串的所有子串中有没有一个长度为26的子串包含所有的26个大写字母。其中问号可以代表任意字符。 没有的话输出-1,有的话吧?补成字母后输出整个字符串。 Special Judge.就枚举瞎暴力,跑出来就随便打,跑不出来就-1.#include <iostre

Benjamin_Z的博客 751

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

CodeForces 716B Complete the Word

题目链接:http://codeforces.com/problemset/problem/716/B 题目大意:   给出一个字符串,判断其是否存在一个子串(满足:包含26个英文字母且不重复,字串中有‘?’表示占位符可表示字母),如果存在则输出该字串‘?’位置用替换后的字母代替,其他不在子串中的‘?’用字母代替即可。如果该字串不存在满足条件的子串,则输出-1. 举例: ---------...

weixin_30293079的博客 85

Complete the Word CodeForces 716B

                                         Complete the Word Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d &amp; %I64u                                                          ...

September_的博客 308

Complete the Word CodeForces - 716B

ZS the Coder loves to read the dictionary. He thinks that a word isniceif there exists asubstring(contiguous segment of letters) of it of length26where each letter of English alphabet appears exa...

weixin_30716725的博客 152

Binary Table (Hard Version)-(思维)

题目描述:点击进入 题意 给你一个大小为n×m的二进制表,这个表由符号 0 和符号 1 组成。 你可以进行这样的操作: 选择属于一个 2 × 2 正方形的 3 个不同的单元格,并更改这些单元格中的符号(将 0 更改为1, 1 更改为 0 )。 你的任务是使表中的所有符号都等于0。您最多可以进行 nm次 操作。 你不需要最小化操作的数量。 思路 这是上一题的加强版,操作次数变为 nm 了,我上一次的代码过不去,无奈只能优化,但也只是对边界处理优化了一下,却神奇过了(神奇神奇,用xy哥的话来说那就是可蒸馏啊)

Cosmic_Tree的博客 1780

k-LCM ( easy version && hard version ) -( 思维 - 构造 )

题目链接(easy):点击进入 题目链接(hard):点击进入 题目 题意 长度为 k 的数组,整个数组的和为 n ,整个数组的最小公倍数不超过 n / 2,让你构造这样一个数组 简单版本k=3,困难版本 3 <= k <= n。 思路 简单版本: 因为明确告诉你了 k = 3 ,同时要求三个数的最小公倍数不能超过 n / 2,所以我们可以根据 n 来构造这个三个数。 首先根据 n 的奇偶性分类讨论 如果 n 是奇数,那么三个数可以变为 n / 2 , n / 2 , 1 ; 如果 n 是偶

Cosmic_Tree的博客 1189

Binary Table (Easy Version)-(思维)

题目描述:点击进入 题意 给你一个大小为n×m的二进制表,这个表由符号 0 和符号 1 组成。 你可以进行这样的操作: 选择属于一个 2 × 2 正方形的 3 个不同的单元格,并更改这些单元格中的符号(将 0 更改为1, 1 更改为 0 )。 你的任务是使表中的所有符号都等于0。您最多可以进行 3nm次 操作。 你不需要最小化操作的数量。 思路1 通过找找规律,我们可以知道一个 2*2 的矩阵 不包含0的可以通过一次操作变为包含3个0的, 包含3个0的通过一次操作可以变为包含2个0的, 包含2个0的通过一次

Cosmic_Tree的博客 840

Codeforces Beta Round #68 - B- Train ( 贪心模拟 )

题目链接:点击进入 题目 题意 偷渡者和控制者玩以下游戏。 火车由 n 节车厢表示,车厢从头到尾用 1 到 n 的正整数编号。偷渡者和控制者最初在两辆不同的货车中。火车每分钟都可能处于两种状态移动或空闲。控制者每分钟都在移动。 控制器有运动方向——火车头或火车尾。在移动期间,控制者对应于其移动方向移动到相邻的货车。如果在他的移动结束时,控制者进入第 1 辆或第 n 辆货车,那么他将移动方向更改为另一侧。换句话说,控制者在整个游戏过程中循环地从火车的头部到尾部然后再返回,在每次移动期间移动一辆车。请注意,

Cosmic_Tree的博客 747

CodeForces - 1549C - Web of Lies( 思维 )

题目链接:点击进入 题目 题意 n个人m对朋友关系( 双向 ),q次操作: 1 u v u与v成为朋友 2 u v u与v朋友关系破灭 3 计算以下过程的答案: 过程:所有易受伤害的贵族同时被杀害,他们的友谊也随之结束。这样,新贵族就有可能变得脆弱。这个过程不断重复,直到没有贵族受到伤害。可以证明,这个过程将在有限的时间内结束。完成此过程后,您需要计算剩余贵族的数量。( 如果满足以下两个条件,则贵族被定义为易受攻击:至少有一个朋友,那位贵族的所有朋友都有更高的权力。) 注意,该过程的结果不会在查询

Cosmic_Tree的博客 634

CodeForces 1267

题目:B–Balls of Buma 题意 给你一个字符串(代表不同颜色),让你插入一个字符(一种颜色)后,可以消掉整个字符串。(相同颜色、长度变长、长度>=3才会抵消) 思路 将原串变成“种类串”(例如:AABBAA—> ABA)后,“种类串”应当是回文串,且长度应该是奇数。 同时,一个可以被消去的串,根据中心对称的同类部分的长度和,应当>=3。中心部分长度应当>=2.满足以上条件,答案为中心部分答案+1; 代码 #include<iostream> #include&

Cosmic_Tree的博客 583

CodeForces - 1549D - Integers Have Friends ( 差分 - 线段树 - 双指针 )

题目链接:点击进入 题目 题意 定义一个友好区间为,存在一个 m ( m >= 2 ),使区间内的所有数 % m 值相等,让你求给定数组的最大友好区间长度。 思路 如果两个数 x , y , 取模后的值相同,则需要满足:| x - y | % mod == 0。 若是一个区间内 % mod 值相等,则是所有差值的 gcd。 所以根据这一特性,我们不难想到对原数组差分,然后区间求 gcd( 区间求 gcd 可以用线段树来实现 ),然后我们再用双指针维护一个 右端点 指定 的情况下 左端点最远 且

Cosmic_Tree的博客 577

CodeForces - 1557C - Moamen and XOR ( 位运算 + 排列组合 )

题目链接:点击进入 题目 题意 规定长度为 n 的数组要是满足 a1a_1a1​&a2a_2a2​&…ana_nan​ >= a1⊕a2⊕a_1 \oplus a_2 \oplusa1​⊕a2​⊕…⊕an\oplus a_n⊕an​ 则认为是胜利。在每个数组元素小于 2k2^k2k 的前提下,问有多少种数组 a 满足胜利的条件。 思路 看到这个 2k2^k2k ,当时就想到多半按位来看。若是固定每一位,然后看 n 个数这一位的与运算 与 n 个数这一位的异或运算。异或运算有个规律,

Cosmic_Tree的博客 569

Codeforces Round #171 (Div. 2) - E - Beautiful Decomposition( 贪心 )

题目链接:点击进入 题目 题意 给你一串值为 n 的二进制串,一个加数可以是 ( + / - ) 2 ^ k ( k >= 0 ) ,求最少的加数凑成 n ( 没有前导零 ) 思路 若这个串只有一个1,显然只需要一次即可; 否则,我们可以用减法来求得这个数,例如:11010 = 100000 + 00010 - 01000 反过来就是 11010 - 00010 + 01000 = 100000 ,也就是用最小的加数使原数(x位)变成2^x( 若原数是11…就是变成2 ^ x,若原数是10…就是变成

Cosmic_Tree的博客 545
上一篇: CodeForces - 182D Common Divisors( kmp + 最大公约数 )
下一篇: CodeForces - 948DPerfect Security ( 01字典树 )
Cosmic_Tree
博客等级 码龄7年 134粉丝 337原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值