Codeforces Round 972 (Div. 2) D. Alter the GCD(二分+gcd性质)

ZYNQ PS-PL数据交互方式总结 一,中断 二,IO方式:MIO EMIO GPIO 三,BRAM或FIFO或EMIF (1)通过BRAM实现PL/PS之间交互 PS 的配置如下图所示。使能 M_AXI_GP0 口,将 FCLK_CLK0 设为 100MHz,使能 PL 至 PS 的中断。 AXI BRAM Controller IP 核连接 PS 的 M_AXI_GP0 口和 BRAM,完成 AXI 接口至 BRAM 接口的转换。 添加BRAM,将BRAM设置为双口RAM,将PORTA与AXI B... 阅读详情

题目

每次给定n(n<=2e5)和两个长为n的数组a,b(1<=ai,bi<=1e9)

需要进行以下操作恰好一次,

操作:选择区间[l,r],将a的[l,r]区间和b的[l,r]区间的数一一对应互换

求换完之后的gcd(a1,a2,...,an)+gcd(b1,b2,...,bn)的最大值

实际t(t<=1e5)组样例,保证sumn不超过5e5

思路来源

乱搞ac+suger_fan代码

题解

固定一个端点时,另一个端点变化时,gcd只有log种,只需要考虑gcd只会变为这个端点值的因子

这个trick hdu5930用过,所以这个题做法很明显,只是不好写,码农题

不妨枚举l,注意到 gcd(a[l,r]),gcd(b[l,r]),gcd(a[r+1,n]),gcd(b[r+n]) 有一个不同的 r 只有 O(log) 个

当然枚举r也可以,这里是枚举r然后二分那log种的,复杂度O(nlog^3),

为了快速求区间gcd所以用了st表,这里的log也考虑上gcd了

代码1(乱搞ac,ST表+二分)

#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<array>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef double db;
typedef pair<int,int> P;
#define fi first
#define se second
#define pb push_back
#define dbg(x) cerr<<(#x)<<":"<<x<<" ";
#define dbg2(x) cerr<<(#x)<<":"<<x<<endl;
#define SZ(a) (int)(a.size())
#define sci(a) scanf("%d",&(a))
#define pt(a) printf("%d",a);
#define pte(a) printf("%d\n",a)
#define ptlle(a) printf("%lld\n",a)
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int N=2e5+10,M=20;
int t,n,lg[N];
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
void init(){
    rep(i,2,N-5)lg[i]=lg[i>>1]+1;
}
struct RMQ{
    int a[N],b[N][M];
    void init(int n){
        rep(i,1,n)b[i][0]=a[i];
        for(int j=1;j<M;++j){
            for(int i=1;i+(1<<j)-1<=n;++i){
                b[i][j]=gcd(b[i][j-1],b[i+(1<<(j-1))][j-1]);
            }
        }
    }
    int G(int l,int r){
        if(l>r)return 0;
        int k=lg[r-l+1];
        return gcd(b[l][k],b[r-(1<<k)+1][k]);
    }
}f,g;
int main(){
    init();
    sci(t);
    while(t--){
        sci(n);
        rep(i,1,n)sci(f.a[i]);
        rep(i,1,n)sci(g.a[i]);
        // if(n==1){
        //     printf("%lld 1\n",f.a[1]+g.a[1]);
        //     continue;
        // }
        f.init(n);g.init(n);
        ll ans=0,cnt=0;
        rep(i,1,n){
            vector<array<int,5>>all;
            all.pb({0,0,g.G(1,i),0,f.G(1,i)});
            if(i>1)all.pb({1,f.G(1,1),g.G(2,i),g.G(1,1),f.G(2,i)});
            while(true){
                array<int,5>las=all.back();
                int l=las[0]+1,r=i-1;
                if(l>r)break;
                while(l<=r){
                    int mid=(l+r)/2;
                    //printf("l:%d r:%d mid:%d\n",l,r,mid);
                    int g1=f.G(1,mid),g2=g.G(mid+1,i),g3=g.G(1,mid),g4=f.G(mid+1,i);
                    if(array<int,4>{g1,g2,g3,g4}==array<int,4>{las[1],las[2],las[3],las[4]})l=mid+1;
                    else r=mid-1;
                }
                if(l>=i)break;
                int g1=f.G(1,l),g2=g.G(l+1,i),g3=g.G(1,l),g4=f.G(l+1,i);
                all.pb({l,g1,g2,g3,g4});
            }
            all.pb({i,0,0,0,0});
            int sz=SZ(all);
            rep(j,0,sz-2){
                //printf("{%d %lld %lld}\n",all[j][0],all[j][1],all[j][2]);
                array<int,5>x=all[j];
                int g1=gcd(gcd(x[1],x[2]),f.G(i+1,n)),g2=gcd(gcd(x[3],x[4]),g.G(i+1,n));
                if(ans<g1+g2)ans=g1+g2,cnt=all[j+1][0]-all[j][0];
                else if(ans==g1+g2)cnt+=all[j+1][0]-all[j][0];
                //printf("i:%d pos:%d [%d,%d] g1:%d g2:%d\n",i,x[0],i,x[0],x[1],x[2]);
            }
        }
        printf("%lld %lld\n",ans,cnt);
    }
    return 0;
}

代码2(suger_fan代码)

很简短,直接维护所有gcd的可能性

不过复杂度没太看出来是多少,ps内也有可能有重复的,但看起来很难卡掉的样子…

from math import gcd
 
for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    sda, sdb = [0] * (n + 1), [0] * (n + 1)
    for i in reversed(range(n)):
        sda[i] = gcd(sda[i + 1], a[i])
        sdb[i] = gcd(sdb[i + 1], b[i])
    pda = 0
    pdb = 0
    ps = []
    ans, ans_c = 0, 1
    for i in range(n):
        ps.append((pda, pdb, 1))
        nps = []
        for x, y, z in ps:
            nps.append((gcd(x, b[i]), gcd(y, a[i]), z))
        nps.sort()
        ps.clear()
        for x, y, z in nps:
            if len(ps) == 0 or (ps[-1][0], ps[-1][1]) != (x, y):
                ps.append((x, y, z))
            else:
                ps[-1] = (ps[-1][0], ps[-1][1], ps[-1][2] + z)
        for x, y, z in ps:
            pans = gcd(x, sda[i + 1]) + gcd(y, sdb[i + 1])
            if pans > ans:
                ans = pans
                ans_c = 0
            if pans == ans:
                ans_c += z
        pda = gcd(pda, a[i])
        pdb = gcd(pdb, b[i])
    print(ans, ans_c)

PCL 使用点云创建数字高程模型DEM【2025最新版】 使用点云创建数字高程模型DEM,并将结果保存为高程图像。博客长期更新,本文最近更新时间为:2025年9月15日。 阅读详情

相关推荐

AI数字人短视频数字人口播数字人分身建模流程全解析

在人工智能与计算机图形学蓬勃发展的当下,数字人建模作为打造虚拟数字人的核心环节,其流程复杂且精妙,融合了多种前沿技术与创意构思,为栩栩如生的数字人形象奠定基石。​。

2403_87518095的博客 1452

codeforces 数论&容斥原理 Count GCD

codeforces 数论&容斥原理 Count GCD

m0_62031207的博客 451

Python手记-9:Python LXML库XPath的爬取晋江书目

1. lxml库 lxml是功能最丰富且易于使用的库,用于处理Python语言中的XML和HTML,还可实现WEB爬取,官文参考:https://lxml.de/,完整的PDF文档下载链接https://lxml.de/lxmldoc-4.5.0.pdf,但是阅读起来……em……怪自己不够聪明的样子。 Linux下安装lxml库:[root@chengyu ~]# pip3 instal...

成屿的专栏 4万+

【Codeforces】CF 2005 D

数论 #枚举 #gcd。

Antonio915的博客 1043

开源网格划分软件-Gmsh二次开发教程 (4)网格生成与控制​

​本章将深入讲解Gmsh的网格生成技术,包括全局/局部网格控制、边界层生成、自适应细化等,并提供完整的代码示例。

ZQGG的博客 1479

ZEMAX知识点:坐标间断面(coordinate break)

zemax知识点:坐标间断面

weixin_47638568的博客 1万+

Codeforces 1459 Row GCD(GCD,结论)

You are given two positive integer sequences ????1,…,???????? and ????1,…,????????. For each ????=1,…,???? find the greatest common divisor of ????1+????????,…,????????+????????. Input The first line contains two integers ???? and ???? (1≤????,????≤2⋅105).

tomjobs的博客 753

百元DIY手机荧光计:低成本荧光检测平台搭建与实战

荧光检测是一种基于物质受特定波长光激发后发射更长波长荧光的分析技术,其核心原理在于光与物质的相互作用。通过选择性激发与检测,该技术能实现对痕量物质的高灵敏度、高特异性定量分析,在生物医学、环境监测和食品安全等领域具有重要价值。传统荧光分光光度计虽精度高,但成本昂贵、体积庞大且操作复杂,限制了其在现场快检和普及教育中的应用。本文聚焦于如何利用智能手机的高性能摄像头和处理器,结合低成本光学滤光片和LED光源,构建一个便携、经济的DIY荧光检测平台。该方案通过简化光路设计,采用带通滤光片进行波长选择,并利用图像处

weixin_34194829的博客 315

Codeforces Round 972 (Div. 2)

(3) 最后我们讨论大卫在两名老师的中间,那么老师肯定会往中间追,大卫往离着最远老师的方向跑,在即将相遇的时候再往回跑,直到有一刻,两名老师同时抓到大卫,时间是(max(x,y)-min(x,y))/2。(2) 老师全在大卫的左边,那么好,我们很容易想到大卫往右边跑直到n为止,离大卫最近的老师追,追到为止,那么时间就是 n-max(x,y);(1)老师全在大卫的右边,那么好,我们很容易想到大卫往左边跑直到1为止,离大卫最近的老师追,追到为止,那么时间就是 min(x,y)-1;

2301_80246513的博客 908

【即插即用模块】卷积篇 | TGRS 2025 | HLKConv:小核+空洞=大核,感受野一致,但更轻更准!

本文介绍了分层大核卷积模块HLKConv,该模块通过动态大核+空洞卷积实现高效感受野扩展,将超大核卷积分解为小核+空洞卷积(如53×53核用17×17+dilation=3实现),计算量仅为普通大核的1/10。模块采用双分支设计:基础卷积分支捕捉局部细节,大核空洞分支捕捉长距离关联,通过1×1卷积融合。实验表明HLKConv在红外小目标检测中优于传统大核卷积,适用于高分辨率视觉任务。代码实现了不同核尺寸的配置,输入输出特征维度保持不变,计算效率显著提升。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 352

银行支付系统系列介绍(一):全国综合业务服务平台——CBSP

7月23日至25日,综合平台首批试点业务顺利上线,共41家入网机构接入综合平台,平台运行稳定、业务处理及时准确。截至7月25日,综合平台共受理明细业务6,330笔,金额总计约2.41亿元,业务涉及工商银行、农业银行、中国银行、交通银行等22家商业银行。全国综合业务服务平台(以下简称综合平台)以提供安全、便捷、高效的便民支付服务为宗旨,支持政府机构、企事业单位办理代收付业务、主动缴费业务以及相关的信息类业务,依托小额支付系统进行资金清算,综合平台7×24小时运行。、实时缴款,由小额支付。

银行信息系统应用架构详解 3209

Codeforces Round 972(Div.2)A+B

Codeforces Round 972(Div.2)A+B

YGGP的博客 1343

从零到多智能体:Google Agent开发套件(ADK)入门指南

ADK促进自定义工具生产的能力是其优势之一。本质上,工具只是一个带有描述性文档字符串的Python函数。

独立开发,substack顶级编辑 2498

Codeforces 798C gcd 找规律

传送门:题目 题意: 给一个序列a,做一些变换,用最少的变换次数,让序列满足 gcd(a[0],a[1],⋯,a[n−1])&gt;1gcd(a[0],a[1],⋯,a[n−1])&gt;1gcd(a[0],a[1],\cdots,a[n-1])>1 变换规则为,相邻两个数:a[i],a[i+1]a[i],a[i+1]a[i],a[i+1],经过变换后为a[i]−a[i+1],a[i]...

shadandeajian的博客 380

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

【CodeForces - 1047C】Enlarge GCD(数学,枚举,预处理打表,思维)

题干: F先生有n个正整数,a1,a2,...,an 他认为这些整数的最大公约数太小了,所以他想通过删除一些整数来扩大它 您的任务是计算需要删除的最小整数数,以便剩余整数的最大公约数大于所有整数的公约数. Input 3 1 2 4 Output 1 Input 4 6 9 15 30 Output 2 Input 3 1 1 1 Output -1 题目大意: ...

xuanweiace的博客 838

假人有限元模型

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

Codeforces Round 972 (Div. 2)(A - C)

从元音字母“aeiou” 中组成字符串使得该字符串的回文子串最少。

honeybadger1的博客 1004

深度学习工具包 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 1459C 数论 GCD

GCD更相减损术应用

_int_me的博客 332

CodeForces 选讲 by zyb

gcd

m0_73430577的博客 2178

Codeforces Round 972 (Div. 2) A-C 题解

本来以为 B2 难度会 1900 什么的,结果感觉 1200 还没有,先做的 B1,后悔了 QwQ关于我现场没切出 C 这件事……

AKDreamer_HeXY的博客 1742

codeforces 972div2 动态规划,记忆化搜索

思路:最开始的思路是预处理分别求出各个字符串中narek分别的数量,然后通过动态规划求解,但是在写的过程的中发现,这样无法处理每读入五个narek分数+ 5的情况,于是改变思路,边扫字符串边dp,遇见narek中的字母让当前分数 - 1如果碰见完整的narek让分数+ 10(因为完整的narek不能算到-1的的分数中去,因此要加10,把减去的分数也加回来)dp[i][当前str的长度] = max(dp[i][当前str的长度], dp[i - 1][j] + scr)如果当前的dp[i][j][k]!

2201_75845839的博客 1387

CodeForces - 664A Complicated GCD (技巧)水

CodeForces - 664A Complicated GCD Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Greatest common divisor GCD(

yanghui07216的博客 1014

CodeForces - 1459C Row GCD (gcd的更相减损术)

题目链接:点击这里 题目大意: 给出一个长度为 nnn 的序列 a1,a2,...ana_1,a_2,...a_na1​,a2​,...an​ ,再给出一个长度为 mmm 的序列 b1,b2,...bmb_1,b_2,...b_mb1​,b2​,...bm​ ,对于第二个序列种的每一个元素 bjb_jbj​ 求: gcd(a1+bj,+a2+bj,...,an+bj)gcd(a_1+b_j,+a_2+b_j,...,a_n+b_j)gcd(a1​+bj​,+a2​+bj​,...,an​+bj​) 题目分析

羊驼的博客 439

codeforces 579 div3 Common Divisors(gcd性质)

题目大意: 有一串数字An,我们要找到能够被An所有数字整除的数字的个数。 解题思路: 其实这道题是考gcd,但是, 以下是我的一点思考过程,可以跳过。 我们假如直接看gcd,发现An的公共除数的边界只能到gcd(a1,a2,a3,...an),但是知道这个边界,我们怎么得到接下来的An所有数字的divisor呢,一个naive的想法是:得到gcd 结果b后,我们 while(b--)...

FrostMonarch的博客 196

【暴力】Codeforces990G GCD Counting

题意: 在一颗树上,每个点有一个权值,求任意两点间路径上所有点的权值的gcd值,以及每个值出现的次数。 分析: 由于每个权值的范围在20000以内,所以能成为多个数的gcd的值很少,于是就可以暴力卡一卡就能过了。 #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;cmath&gt; #include&lt;al...

氧化钠的博客 670

codeforces A. EhAb AnD gCd

题目 题意: 给你一个数nnn,要求你求出满足GCD(a,b)+LCM(a,b)=nGCD(a, b) + LCM(a, b) = nGCD(a,b)+LCM(a,b)=n中,a,ba,ba,b的值。 思路: 很简单我们都知道GCD(1,n)=1,LCM(1,n)=nGCD(1,n) = 1,LCM(1,n) = nGCD(1,n)=1,LCM(1,n)=n那么我们把nnn换成n−1n-1n−1...

忘梦心的博客 1002

Codeforces D - GCD of Polynomials

D - GCD of Polynomials 逆推,根据(i-2)次多项f(i-2)式和(i-1)次多项式f(i-1)推出i次多项式f(i) f(i)=f(i-1)*x+f(i-2) 样例已经给出0次和1次的了 注意系数绝对值大于1对2取模 代码: #include<bits/stdc++.h> using namespace std; #define ll lo...

weixin_34279246的博客 229
上一篇: The 2024 ICPC Asia East Continent Online Contest (I) L. Bull Farm(性质题+有向图可达性/最短路)
下一篇: Codeforces Round 973 (Div. 2) E. Prefix GCD(n个数重排使得gcd前缀和最小 补写法)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

小衣同学

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

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址