A Simple Problem with Integers 线段树

ABAQUS中CDP模型在钢筋混凝土节点低周反复荷载模拟的关键技术解析 本文深入解析了ABAQUS中CDP模型在钢筋混凝土节点低周反复荷载模拟中的关键技术。通过详细介绍CDP模型的核心价值、建模关键技术、滞回曲线优化方法及典型问题排查指南,帮助工程师精准模拟混凝土的拉伸开裂和压缩压碎行为,提升抗震分析效率。文章还提供了实用的工程应用技巧,如快速建模模板和后处理自动化脚本。 阅读详情

郭炜老师的代码  写了下注释 线段树的经典题目

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

struct CNode
{
    int L,R;
    CNode * pLeft, * pRight;
    long long nSum;//和
    long long Inc;//区间累加量
};
CNode Tree[200010];
int nCount = 0;//充当一个指针作用,管理内存


int Mid( CNode * pRoot)
{
    return (pRoot->L + pRoot->R)/2;//返回区间中间值
}


void BuildTree(CNode * pRoot,int L, int R)//建树
{
    pRoot->L = L;
    pRoot->R = R;
    pRoot->nSum = 0;
    pRoot->Inc = 0;
    if( L == R)//叶节点返回
        return;
    nCount ++;
    pRoot->pLeft = Tree + nCount;
    nCount ++;
    pRoot->pRight = Tree + nCount;
    BuildTree(pRoot->pLeft,L,(L+R)/2);
    BuildTree(pRoot->pRight,(L+R)/2+1,R);
}
void Insert( CNode * pRoot,int i, int v)//插入值 第i个 值为V
{
    if( pRoot->L == i && pRoot->R == i)//如果为叶子节点直接加上累加量结束
    {
        pRoot->nSum = v;
        return ;
    }
    pRoot->nSum += v;//非叶子节点,在该区间加上累加量继续向下一层更新
    if( i <= Mid(pRoot))//小于中间的区间
        Insert(pRoot->pLeft,i,v);
    else//大于中间的区间
        Insert(pRoot->pRight,i,v);
}
void Add( CNode * pRoot, int a, int b, long long c)
{
    if( pRoot->L == a && pRoot->R == b)//区间和目标区间相同,直接加到区间的增加量上就行
    {
        pRoot->Inc += c;
        return ;
    }
    pRoot->nSum += c * ( b - a + 1) ;//如果不相同 把值加到总增加量上后继续向下一层进行
    if( b <= (pRoot->L + pRoot->R)/2)//如果[a,b]完全在中间左边则向左递归
        Add(pRoot->pLeft,a,b,c);
    else if( a >= (pRoot->L + pRoot->R)/2 +1)//同理
        Add(pRoot->pRight,a,b,c);
    else//跨过两边,同理
    {
        Add(pRoot->pLeft,a,(pRoot->L + pRoot->R)/2,c);
        Add(pRoot->pRight,(pRoot->L + pRoot->R)/2 + 1,b,c);
    }
}
long long QuerynSum( CNode * pRoot, int a, int b)
{
    if( pRoot->L == a && pRoot->R == b)
        return pRoot->nSum +(pRoot->R - pRoot->L + 1) * pRoot->Inc ;//如果到达查询的目标区间 直接返回累计值加上区间每一个元素的增加值的和,就是答案
    pRoot->nSum += (pRoot->R - pRoot->L + 1) * pRoot->Inc ;//把区间值加到累计值上往下面带
    Add( pRoot->pLeft,pRoot->L,Mid(pRoot),pRoot->Inc);//
    Add( pRoot->pRight,Mid(pRoot) + 1,pRoot->R,pRoot->Inc);
    pRoot->Inc = 0;//往下带完之后记得归零
    if( b <= Mid(pRoot))      //和上面ADD同理  查绚区间分布不同的三种情况
        return QuerynSum(pRoot->pLeft,a,b);
    else if( a >= Mid(pRoot) + 1)
        return QuerynSum(pRoot->pRight,a,b);
    else
    {
        return QuerynSum(pRoot->pLeft,a,Mid(pRoot)) + QuerynSum(pRoot->pRight,Mid(pRoot) + 1,b);
    }
}
int main()
{
    int n,q,a,b,c;
    string  cmd;
    while(scanf("%d%d",&n,&q)==2){
    nCount = 0;
    BuildTree(Tree,1,n);
    for(int  i = 1; i <= n; i ++ )
    {
        scanf("%d",&a);
        Insert(Tree,i,a);
    }
    for( int i = 0; i < q; i ++ )
    {
       cin>>cmd;
        if ( cmd[0] == 'C' )
        {
            scanf("%d%d%d",&a,&b,&c);
            Add(Tree,a,b,c);
        }
        else
        {
            scanf("%d%d",&a,&b);
            printf("%lld\n",QuerynSum(Tree,a,b));
        }
    }
    }
    return 0;
}

 

Sipeed麦克风阵列板练习 麦克风阵列板 Maix Dock Sipeed 阅读详情

相关推荐

差分运算放大电路实战:如何用OP07搭建高精度信号采集系统(附电路图)

本文以OP07高精度运算放大器为核心,详细阐述了差分运算放大电路的设计与实现。针对微弱信号采集中的共模干扰难题,文章从电路选型、核心器件剖析、实战电路设计、PCB布局到实测验证,提供了完整的工程实践指南,并附有电路图,旨在帮助工程师构建稳定可靠的高精度信号采集前端系统。

ss78901的博客 1029

A Simple Problem with Integers(线段树 / 树状数组)

题目链接: A Simple Problem with Integers 大致题意 有两种操作: ​ ①给区间[l, r]所有元素增加c ​ ②查询区间[l, r]中所有元素值的和 解题思路 线段树区间修改 + 区间查询, 维护的数值为区间中的元素和 同样本题也提供一种树状数组的做法. AC代码(线段树做法) #include <iostream> #include <cstdio> #define rep(i, n) for (int i = 1; i <= (n); ++i

Fau的博客 1224

保姆级教程:手把手调试PX4Ctrl的油门映射与姿态控制(附ROS节点配置)

本文提供PX4Ctrl的深度调参指南,涵盖油门映射、姿态控制及ROS节点配置等关键环节。通过详细解析PX4控制器的核心逻辑、递归最小二乘法(RLS)参数估计及状态机设计,帮助开发者优化无人机飞控性能。附实战案例与安全调试建议,适合PX4开发者进阶学习。

weixin_30363981的博客 385

A Simple Problem with Integers (线段树)

Description You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The othe...

240

微信小程序推送微信服务号模板消息

微信小程序中发送微信服务号模板消息,无需用户手动确认订阅,无需绑定开放平台,无需使用UnionId。

qq_20751269的博客 1574

基于大模型与知识图谱的对话引导意图澄清系统技术解析

本文提出了一种基于知识图谱与大语言模型的意图澄清系统,旨在解决传统RAG模型在跨文档推理和主动澄清方面的不足。系统通过知识图谱驱动的多跳推理机制和链式思维引导的对话流程,实现了动态信息补全和意图澄清。核心创新包括:1)知识图谱构建与节点选择算法;2)标签探索策略与原子事实提取方法;3)主动澄清引擎的工作流程。实验表明,该系统能有效提升复杂查询的准确率,在医疗、金融等领域实现精准交互。关键代码展示了节点选择、标签匹配和事实提取等核心组件的实现细节。

420

训练之线段树A Simple Problem with Integers

A Simple Problem with IntegersCrawling in process... Crawling failed Time Limit:5000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu Submit Status Description Inpu

萌白的博客 369

解锁IPG Photonics SmartWeld系统,开启焊接新时代

SmartWeld 系统是 IPG Photonics 研发的一款先进的激光焊接解决方案,它隶属于自动化激光焊接系统类别 ,但却凭借一系列创新技术和独特设计,在众多同类产品中脱颖而出。该系统基于 IPG 在光纤激光技术领域的深厚积累,融合了先进的光束控制、智能监测和自动化控制等技术,旨在为工业制造提供高效、精准且稳定的焊接工艺。与传统激光焊接系统相比,SmartWeld 系统的独特之处首先体现在其光束控制技术上。它能够精确地调整激光束的能量分布、光斑大小和形状 ,以适应不同材料和焊接工艺的需求。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1441

ACM——A Simple Problem with Integers(线段树的精华版)

Description 给出了一个序列,你需要处理如下两种询问。 "Ca b c"表示给[a, b]区间中的值全部增加c(-10000 ≤c≤ 10000)。 "Qa b" 询问[a, b]区间中所有值的和。 Input 第一行包含两个整数N, Q。1 ≤N,Q≤ 100000. 第二行包含n个整数,表示初始的序列A(-1000000...

weixin_30633949的博客 131

基于YOLOv8和时序模型的异常动作检测系统

异常动作检测是计算机视觉领域的重要应用,广泛应用于智能监控、安防系统、老人看护等场景。本项目结合YOLOv8目标检测和LSTM时序模型,实现对打架、摔倒、奔跑等异常动作的实时检测,并提供了完整的Web界面。多技术融合: 结合YOLOv8目标检测和LSTM时序建模实时检测: 支持实时视频流处理和文件分析用户友好: 提供完整的Web界面可扩展性: 模块化设计便于功能扩展高性能: 包含多种优化策略。

YOLO 767

突破限制:巧用Azure OpenAI,畅玩Gemini模型

通过 Azure OpenAI 服务这一巧妙的途径,间接调用 Gemini 模型,打破网络限制的壁垒。本文将详细介绍这一方法,无论你是人工智能领域的新手,还是经验丰富的开发者,都能从中获取实用的技巧,轻松开启 Gemini 模型的探索之旅

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 191

kuangbin 专题七 线段树(POJ 3468)A Simple Problem with Integers

A Simple Problem with Integers Time limit 5000 ms Case time limit 2000ms Memory limit 131072 kB OS Linux You have N integers, A1, A2, … , AN. You need to deal with two kinds of operation...

Istil 216

UNet + Shuffle Attention:一种轻量高效的医学图像分割注意力机制

本文提出了一种轻量高效的医学图像分割方法,将Shuffle Attention模块嵌入UNet的上采样路径中。Shuffle Attention通过通道分组注意力机制增强关键特征,同时保持计算轻量化。该方法在上采样后应用注意力模块,有效融合高层语义与低层细节,计算开销小且易于部署。实验表明,该模型在保持UNet原有优势的基础上,通过注意力机制提升了特征聚焦能力,适用于多种图像分割任务。未来可进一步结合空间注意力或Transformer模块以增强模型性能。

Henry的博客 243

线段树——A Simple Problem with Integers

线段树——A Simple Problem with Integers You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given inte...

linjiayina的博客 329

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

线段树 A Simple Problem with Integers

Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other i

杭锦泉的博客 292

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

A Simple Problem with Integers(线段树)

树没有更新成功,id=10,id=11理论上是要继续更新他们的sum值,但我的错误代码没有更新。关键在于updatespan函数中,if语句中我没有继续pushdown导致错误。不要看这题全英文,但这题就是属于线段树模版题,基本做法是一样的。

weixin_62063623的博客 1183

假人有限元模型

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

【线段树】A Simple Problem with Integers

A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 171549 Accepted: 52831 Case Time Limit: 2000MS Description You have N integers, A1, A2, … , AN. You need to...

CTGU_UN_GO的博客 274

3468 A Simple Problem with Integers 线段树

#include struct node { int L,R; __int64 sum,inc; }; node tree[500000]; void build(int k,int left, int right) { tree[k].L=left; tree[k].R=right; tree[k].sum=0; tree[k].inc=0; if (left==ri

山西王志强的专栏 846

POJ 3468 A Simple Problem with Integers 线段树

线段树模版题。 贴个代码。 #include #include #include #include #include #include #include #include #include #include #include #include #define PI acos(-1.0) #define Max 100005 #define inf 1<<28 using

just_water 1329

A Simple Problem with Integers 【线段树】

题目链接:POJ-3468 [kuangbin带你飞]专题七 线段树 题目描述: You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a give...

Hang_ccccc的博客 213

POJ3468,A Simple Problem with Integers,线段树

题目链接: POJ3468 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 77541   Accepted: 23874 Case Time Limit: 2000MS Descrip

北 496

【线段树】A Simple Problem with Integers poj ——3468

A Simple Problem with Integers You have NNN integers, A1,A2,...,ANA1, A2, ... , ANA1,A2,...,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each...

我の名字 225

线段树 POJ 3468 A Simple Problem with Integers

Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other i

Advanced_hwr的博客 683

HDU4267 A Simple Problem with Integers 线段树

A Simple Problem with IntegersA\ Simple\ Problem\ with\ IntegersA Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32...

qq_43710979的博客 175

A Simple Problem with Integers BZOJ3212 线段树

A Simple Problem with Integers BZOJ3212 线段树 You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given nu...

loooooog的博客 347

POJ3468 A Simple Problem with Integers 线段树

A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 152613 Accepted: 47315 Case Time Limit: 2000MS Description You have N integers, A1, A2, … , AN. You need to...

DouglasConnor的博客 218
上一篇: Radar Installation
下一篇: Cow Contest POJ - 3660 floyed
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值