Codeforces Round #538 (Div. 2) F - Please, another Queries on Array?(线段树+位运算维护集合)

手把手教你用FPGA解析AD9680的JESD204B数据流(附Verilog代码) 本文详细介绍了如何利用FPGA解析AD9680的JESD204B数据流,包括协议核心机制、硬件平台搭建、Verilog代码实现及调试技巧。通过实战案例和代码示例,帮助工程师快速掌握高速ADC数据采集与处理技术,提升系统性能。 阅读详情

题目

给一一个n<=4e5的序列a[],ai<=300

两种操作,操作数q<=2e5

一种是区间[l,r]乘上一个值x 

另一种是询问区间[l,r]乘积的欧拉函数值

思路来源

各路cf神仙代码

 

题解1

维护区间积和区间或,

先把300以内的质数筛出来,然后每个数质因数分解

每个数有哪些质数对应用位运算压位,bitset也可以

这样两个数相乘的时候,它们乘积的质因子就是二者的并集

求欧拉函数\varphi (x)的时候,先求区间积,

然后看质因子有哪些,

压位的第i位为1说明有prime[i],乘以prime[i]/(prime[i]-1)即可

由于是mod意义下的运算,再先搞一下逆元

代码1

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=(1<<20)+5;
const int maxm=4e5+5;
const int maxv=310;
bool ok[maxv];
ll prime[maxv],id[maxv],cnt;
ll inv[maxv],mask[maxv];
int n,q;
ll a[maxm];
char op[20]; 
ll modpow(ll x,ll n,ll mod)
{
	if(n==0)return 1;
	ll p=modpow(x,n/2,mod),res=p*p%mod;
	if(n&1)(res*=x)%=mod;
	return res;
}
struct dat
{
	ll mul,mask;
	dat():mul(1),mask(0){}
	dat(ll a,ll b):mul(a),mask(b){}
	dat operator+(const dat &rhs)const
	{
		return dat((mul*rhs.mul)%mod,mask|rhs.mask);
	}
}e[maxn],lazy[maxn];
void pushup(int p)
{
	e[p]=e[p<<1]+e[p<<1|1];
}
void build(int p,int l,int r)
{
	if(l==r)
	{
		e[p]=dat(a[l],mask[a[l]]);
		return;
	}
	int mid=(l+r)>>1;
	build(p<<1,l,mid);
	build(p<<1|1,mid+1,r);
	pushup(p);
}
void app(int p,int l,int r,dat v)
{
	lazy[p]=lazy[p]+v;
	v.mul=modpow(v.mul,(r-l+1)%(mod-1),mod);//费马
	e[p]=e[p]+v; 
}
void pushdown(int p,int l,int r)
{
	int mid=(l+r)>>1;
	app(p<<1,l,mid,lazy[p]);
	app(p<<1|1,mid+1,r,lazy[p]);
	lazy[p]=dat(1,0);
}
void update(int p,int l,int r,int ql,int qr,dat v)
{
	if(ql<=l&&r<=qr)
	{
		app(p,l,r,v);
		return;
	}
	int mid=(l+r)>>1;
	pushdown(p,l,r);
	if(ql<=mid)update(p<<1,l,mid,ql,qr,v);
	if(qr>mid)update(p<<1|1,mid+1,r,ql,qr,v);
	pushup(p);
}
dat query(int p,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr)return e[p];
	int mid=(l+r)>>1;
	pushdown(p,l,r);
	return (ql<=mid?query(p<<1,l,mid,ql,qr):dat(1,0))+(qr>mid?query(p<<1|1,mid+1,r,ql,qr):dat(1,0)); 
}
void init()
{
	for(ll i=2;i<=300;++i)
	{
		if(!ok[i])
		{
		 prime[cnt]=i;
		 id[i]=cnt++;
	    }
		for(ll j=0;j<cnt;++j)
		{
			ll k=i*prime[j];
			if(k>300)break;
			ok[k]=1;
			if(i%prime[j]==0)break;
		}
	}
	for(ll i=2;i<=300;++i)
	{
		ll tmp=i;
		for(int j=0;j<cnt;++j)
		{
			if(prime[j]*prime[j]>tmp)break;
			if(tmp%prime[j]==0)
			{
				mask[i]|=(1ll<<id[prime[j]]);
				while(tmp%prime[j]==0)
				tmp/=prime[j];
			}
		}
		if(tmp>1)mask[i]|=(1ll<<id[tmp]);
	} 
	inv[1]=1;
	for(ll i=2;i<=300;++i)
	inv[i]=modpow(i,mod-2,mod);
}
int main()
{
	init();
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;++i)
	scanf("%I64d",a+i);
	build(1,1,n);
	while(q--)
	{
		int l,r,v;
		scanf("%s%d%d",op,&l,&r);
		if(op[0]=='M')
		{
			scanf("%d",&v);
			update(1,1,n,l,r,dat(v,mask[v]));
		}
		else 
		{
			dat ans=query(1,1,n,l,r);
			for(int i=0;i<cnt;++i)
			{
				if(ans.mask&(1ll<<i))
				(ans.mul*=(prime[i]-1)*inv[prime[i]]%mod)%=mod;
			}
			printf("%I64d\n",ans.mul);
		}
	}
	return 0;
}

 

强化学习环境Gym库的介绍 Gym是一个用于进行强化学习实验的开源库,它提供了一个仿真环境,内置了多种仿真游戏,例如出租车游戏、悬崖游戏等,不同的游戏所用的网格、规则、奖励(reward)都不一样,适合为强化学习做测试。(1) 多种环境:Gym库内置了上百种实验环境,包括算法环境、简单文本环境、经典控制环境、Atari游戏环境、MuJoCo环境和机械控制环境等。(2) Gym提供多种环境供我们使用,这里以一个简单的CartPole-v0为例,首先导入gym库,然后创建一个CartPole-v0环境,通过调用gym.make方法实现。 阅读详情

相关推荐

泛微OA与金蝶云星空深度集成实战:审批与表单双场景解析

本文深入解析泛微OA与金蝶云星空的深度集成实战,聚焦审批流程与表单对接两大核心场景。通过具体案例,详细阐述了如何实现业务数据与审批流程的自动联动,打破数据孤岛,提升企业运营效率与数据一致性,并分享了接口设计、安全策略及实战避坑指南。

4k5l6j7h8的博客 474

CF1114F. Please, another Queries on Array?

没有注意到所有的因子都是300以内,注意到了也想不到这样就可以用集合来表示质数是否出现,从而直接计算出欧拉函数。 打标记的线段树在change的时候忘记pushdown了,调了一天orz #include &amp;amp;lt;iostream&amp;amp;gt; #include &amp;amp;lt;cstdio&amp;amp;gt; #include &amp;amp;lt;string&amp;amp;gt; #include &am

zz_ylolita 412

ESP32-S3射频测试与全球认证全栈实践指南

功率谱密度(PSD)和发射功率等级是无线通信设备射频合规的核心基础概念,其物理层原理直接决定自适应测试、阻塞容限及多国认证的通过路径。PSD ≥10 dBm/MHz触发强制性自适应测试,需验证LBT机制与跳频鲁棒性;而16级可编程发射功率等级(-24 dBm至+20 dBm)则为功耗、覆盖与法规平衡提供工程调控维度。该能力广泛应用于低功耗蓝牙IoT终端、智能家居网关及工业无线传感器等场景,尤其在ESP32-S3平台中,需结合eFuse校准、Sigma工具链与QuickTrack认证策略实现从实验室调试到量产

weixin_34945060的博客 297

Xenia and Bit Operations 【CodeForces - 339D】【线段树+位运算】

题目链接 这道题难理解也就在于题意了,题目要求的是对于原来的这个数(一共(1&lt;&lt;N)个数)进行两两之间先或运算再亦或运算,因为数的个数刚好是2^N次,所以直接就是一个完全二叉树,直接线段树的做法即可了。 每个查询会改变某一点的值,然后输出整个的答案。 #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &...

既然弱小,就只顾变强就是了 379

新手必看:如何用R/qtl快速完成QTL定位分析(附实战代码)

本文为新手提供了使用R/qtl进行QTL定位分析的完整实战指南。内容涵盖从环境搭建、数据准备与清洗,到核心分析流程(包括遗传图谱计算、单QTL扫描、置换检验确定阈值)以及进阶结果可视化的全步骤。通过清晰的代码示例,帮助读者快速掌握这一数量遗传学关键分析技术,实现从数据到QTL峰值的完整分析闭环。

y7z8a的博客 515

STM32F103VET6实战:用W25Q64外部Flash实现Bootloader+Application双备份(含完整代码解析)

本文详细介绍了基于STM32F103VET6微控制器和W25Q64外部Flash实现Bootloader+Application双备份固件升级的完整方案。通过精心设计的Flash分区策略、可靠的Bootloader程序以及包含双重校验和自动回滚机制的升级流程,有效解决了远程升级过程中断电导致设备变砖的风险,确保了工业嵌入式系统的高可靠性与稳定性。

linux的博客 829

Codeforces 482B Interesting Array(位运算+差分+线段树)

巧妙的题目。

ZZY的博客 273

别自己写CDC了!聊聊Xilinx AXI4-Stream Clock Converter IP里的寄存器管道模式到底有多省资源

本文探讨了Xilinx AXI4-Stream Clock Converter IP核的寄存器管道模式在FPGA设计中的高效资源利用。通过对比手工CDC实现,详细解析了IP核的精简化同步架构和时序收敛优势,并提供了实战案例和优化策略,帮助工程师快速实现时钟域转换,显著提升设计效率和性能。

weixin_33738555的博客 445

CodeForces 703D Mishka and Interesting sum(线段树+异或)

给定一个数列,m次查询 每次查询输出某个区间的出现数字为偶数的数字的异或 对于异或可以知道,偶数个相同数字异或为本身,那么我们容易知道 对于询问 q[l,r]=y[l,r]^c[l,r] q为某个区间出现次数为偶数的数字异或 y为某个区间异或之和 c为某个区间所有不相同的数字的异或之和 对于y我们可以预处理出来 O(1)查询 对于不同数字的异或  我们用线段树来查询

宝树啊宝树 670

ESP32语音交互实战:离线唤醒与DeepSeek大模型集成

本文详细介绍了如何将ESP32-S3开发板与天问ASRPRO语音模块结合,实现离线语音唤醒并集成DeepSeek大模型的智能交互系统。通过串口通信与API调用,系统可处理本地指令及复杂语义请求,适用于低成本、高隐私保护的AIoT语音交互场景。

rust6ferris的博客 881

实干派!网易易盾增强版滑块验证码,全方位讲解识别思路(含源码)

该验证码是异形滑块验证码中的一种,缺口旋转+偏移的处理需要你有很好的图像处理知识,能很好的处理透明通道,同时,该验证码需要你能很好的处理缺口和背景之间匹配的关系,该验证码的处理难点就是两个缺口之间如何找到正确的,两个检测框都有很强的相似度,且加上背景图的干扰,在图像处理和有优化上难度大大增加。

码王吴彦祖的博客 2021

求集合中选一个数与当前值进行位运算的max

求集合中选一个数与当前值进行位运算的max 这是一个听来的神仙东西。 先确定一下值域把,大概\(2^{16}\),再大点也可以,但是这里就只是写写,所以无所谓啦。 我们先看看如果暴力求怎么做,位运算需要给定\(01/10,00,11\)的关系,总共\(8\)种。 如果是暴力的话,我们的方法有两种, 第一种是比较喜闻乐见的, 我们对于当前数\(x\),暴力计算所有存在的数\(a_i\)中,\(x\o...

weixin_30265103的博客 160

苹果生态最佳搭档:Mac mini + OpenClaw + iPhone 远程控制

本文详细介绍如何通过iPhone远程控制Mac mini上的OpenClaw应用,打造高效苹果生态工作流。内容包括:1) 苹果生态整合优势,包括AirDrop、Handoff等功能对比;2) Mac mini配置步骤,涵盖SSH/VNC设置、网络优化及Docker部署OpenClaw;3) iPhone端SSH/VNC客户端选择与Tailscale内网穿透配置;4) 详细SSH密钥设置与连接测试方法。通过这套方案,用户可实现跨设备无缝控制OpenClaw应用,提升远程工作效率。(149字)

一键难忘的博客 799

Codeforces Round #538 (Div. 2)F Please, another Queries on Array? (数论+线段树+状态压缩)

题目链接:http://codeforces.com/contest/1114 题目大意: 查询结构, 初始给定一个序列,支持两种操作, 一种是 在区间上每个数都乘上一个x, 一种是查询区间上每个数累乘后的结果的欧拉函数。 题目分析:  这道题应该是 比较简单的, 主要感觉还是考验代码功底吧。 观察欧拉函数的性质即可, euler(n)=n*{因子乘积(1-1/p)}形式, 打表发现...

满月照亮的路 528

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

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

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

Please, another Queries on Array?(Codeforces Round #538 (Div. 2)F+线段树+欧拉函数+bitset)

题目链接 传送门 题面 思路 设\(x=\prod\limits_{i=l}^{r}a_i\)=\(\prod\limits_{i=1}^{n}p_i^{c_i}\) 由欧拉函数是积性函数得: \[ \begin{aligned} \phi(x)&=\phi(\prod\limits_{i=1}^{n}p_i^{c_i})&\\ &=\prod\limits_{...

di6499的博客 144

深度学习工具包 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 Round #538 (Div. 2) F. Please, another Queries on Array?】欧拉函数+线段树+状压

F. Please, another Queries on Array? 题意 给你一个长度为n的序列,序列中第i个数为aia_iai​,1≤ai≤3001 \leq a_i \leq 3001≤ai​≤300 之后有q次操作,每次操作有两种形式 1:区间乘x,1≤x≤3001 \leq x \leq 3001≤x≤300 2: 询问区间乘积的欧拉函数。 1≤n≤4∗1051 \leq n \...

lajiyuan的博客 283

Codeforces Round #538 (Div. 2) F. Please, another Queries on Array? 线段树 + 欧拉函数

传送门 文章目录题意:思路: 题意: 给你一个序列aaa,你需要实现两种操作: (1)(1)(1) 将[l,r][l,r][l,r]的aia_iai​都乘rrr。 (2)(2)(2) 求ϕ(∏i=lrai) mod 1e9+7\phi(\prod_{i=l}^ra_i)\bmod 1e9+7ϕ(∏i=lr​ai​)mod1e9+7 1≤n≤4e5,1≤1≤2e5,1≤ai,r≤3001\le n\le 4e5,1\le 1\le 2e5,1\le a_i,r\le 3001≤n≤4e5,1≤1≤2e5,1≤

m0_51068403的博客 187

Codeforces-1114F:Please, another Queries on Array?(线段树)

F. Please, another Queries on Array? time limit per test 5.5 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a1,a2,…,an.a_1,a_2,…,a_n.a1​...

Mitsuha_的博客 635

F. Please, another Queries on Array? (线段树维护区间积的欧拉函数)

传送门 给定序列,两种操作,区间每个数乘v,求区间积(对1e9+7取模)后的欧拉函数。 序列每个数以及v都不超过300。 首先bd得到欧拉函数的计算公式: 首先序列每个数不超过300,v也不超过300,300以内的质数很少,打表发现只有62个,这个信息显然很有用。 区间欧拉函数就是区间积,很明显可以用线段树维护 。 质因子项我们可以预处理+逆元得到,用f[i]表示第i个质数p[i]的 (p[i]-1)/p[i] % mod 关键是x在乘完之后要取模,取模后求的质因子肯定是错了的,所以我们维护区间积的同

矮纸斜行闲作草 348

codeforces - 1114F Please, another Queries on Array?

题目来源:http://codeforces.com/contest/1114/problem/F 题意: 给定一个序列c,给定两种操作 (1)对区间[l,r]中所有元素*x。 (2)查询区间[l,r]中所有元素成积的欧拉函数值。 数组c的所有元素均&lt;300,每次乘操作的x也均&lt;300。 可以预先得知,300以内的素数共有62个,可以预先保存到数组中。 求取区间内所有数的...

No cost too great! 335

「一题多解」【CodeForces 85D】Sum of Medians(线段树 / 分块)

题目链接 【CodeForces85D】Sum of Medians 题目大意 实现一个setsetset,支持插入,删除,求∑a5k+3∑a5k+3\sum a_{5k+3}。注意,setsetset中的数在任何时刻都应该是排好序的。 题解 I 首先想到离线处理,每一个数字有一个离散化后的编号。 线段树的每一个节点维护五个值,分别表示∑a5k+t∑a5k+t\sum{a_{5...

Galaxy Coder 的博客 449

【交互题】【概率】codeforces1114E Arithmetic Progression

This is an interactive problem! An arithmetic progression or arithmetic sequence is a sequence of integers such that the subtraction of element with its previous element (xi−xi−1, where i≥2) is consta...

BUAA_Alchemist的博客 741

E. Array Queries

E. Array Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output a is an array of n positive integers, al

Nice_punch的博客 619

CF 1114F Please, another Queries on Array?(欧拉函数&线段树)

F. Please, another Queries on Array?(欧拉函数&amp;线段树) 1114F - Please, another Queries on Array? 题目大意 给出一段序列.现可对其进行两种操作.其一是将一段区间l到r之间的所有数乘上某个值x,其二是求一段区间l到r的ϕ(∏lrai)\phi(\prod^r_la_i)ϕ(∏lr​ai​)其中ϕ\phiϕ为求欧拉...

FLY_WHITE的博客 511

【Codeforces Round #538 (Div. 2)】A.B.C.D.E.F

前言 好久之前打的这场比赛,刚刚打算补上题解,赛中由于读错D题题意导致崩盘,本来前期非常顺利但是D卡了一个半小时才知道题意读错了,赛后补过了DEF。 lajiyuan rating−=32rating-=32rating−=32 2002-&amp;gt;1970 A. Got Any Grapes? 题意 【模拟题】略过 做法 【模拟题】略过 代码 #include&amp;lt;stdio.h&amp;gt; i...

lajiyuan的博客 591

【Codeforces Round #538 (Div. 2)】A B C D E F

A 题意有三个人 A 只吃绿葡萄 B 只吃绿葡萄和紫葡萄 C什么葡萄都吃 A B C 三人分别要吃 x y z个葡萄 然后给你 a b c代表 绿 紫 黑葡萄数 问你能不能满足 做法 满足的情况很少 所以初始化不满足 特判满足即可 #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;iostream&gt; #inc...

我是谁 --- 卡比兽 432

CCF-CSP认证 202303 500分题解

202303-1 田地丈量(矩阵面积交) 202303-2垦田计划(二分) 202303-3LDAP(模拟+栈+bitset) 202303-4星际网络II(线段树) 202303-5 施肥(分治+线段树+树状数组) 60分题解(O(n^2+nm)暴力) 75分题解(特殊性质) 100分题解(分治+线段树+树状数组)

小衣同学的博客 1万+
上一篇: 约数定理相关(知识整理+板子总结)
下一篇: 原根(知识学习+板子总结+例题+应用)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址