维护序列

解题思路
线段树模板题
code
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int n,m,mod;
struct abc{
int s;
int flg1,flg2;
}tree[400010];
void build(int now,int l,int r)
{
tree[now].flg1=1;
if(l==r)
{
scanf("%lld",&tree[now].s);
return;
}
int mid=(l+r)/2;
build(now*2,l,mid);
build(now*2+1,mid+1,r);
tree[now].s=(tree[now*2].s+tree[now*2+1].s)%mod;
}
void down(abc &now,abc &l,abc &r,int x,int y)
{

本文介绍了如何使用线段树模板解决维护序列的编程问题,提供了解题思路和具体代码实现,适用于在线判题平台YbtOJ/Luogu。
最低0.47元/天 解锁文章
166

被折叠的 条评论
为什么被折叠?



