质能方程:$E=mc^2$
$$E=mc^2$$
公式$\sum_{i = 1}^m \mu(in)$公式
公式\(\sum_{i = 1}^m \mu(in)\)公式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
#include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #include<climits> #include<string> #include<cstring> #include<cstdlib> #include<vector> #include<queue> #include<map> #include<set> #define LL long long using namespace std; inline char nc(){ /* static char buf[100000],*p1=buf,*p2=buf; if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; } return *p1++; */return getchar(); } inline void read(int &x){ char c=nc();int b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b; } inline void read(LL &x){ char c=nc();LL b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b; } inline void read(char &x){ for (x=nc();!(x=='('||x==')');x=nc()); } inline int read(char *s) { char c=nc();int len=1; for(;!(c=='('||c==')');c=nc()) if (c==EOF) return 0; for(;(c=='('||c==')');s[len++]=c,c=nc()); s[len++]='\0'; return len-2; } int wt,ss[19]; inline void print(int x){ if (x<0) x=-x,putchar('-'); if (!x) putchar(48); else { for (wt=0;x;ss[++wt]=x%10,x/=10); for (;wt;putchar(ss[wt]+48),wt--);} } inline void print(LL x){ if (x<0) x=-x,putchar('-'); if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);} } int n,m,a[300010],A[300010],B[300010]; struct data { int a,b,tag,sum; }tree[1200010]; const int mo=1000000009; void pre() { A[1]=1,A[2]=0; B[1]=0,B[2]=1; for (int i=3;i<=300005;i++) A[i]=(A[i-1]+A[i-2])%mo,B[i]=(B[i-1]+B[i-2])%mo; } int calc(int x,int y,int l) { //cout<<A[4]<<endl; return ((x*A[l+2]%mo+y*B[l+2]%mo)%mo-y+mo)%mo; } int F(int x,int y,int l) { return (x*A[l]%mo+y*B[l]%mo)%mo; } void Pushdown(int x,int l,int r) { //cout<<x<<" "<<l<<" "<<r<<endl; //cout<<"tree[x]="<<tree[x].a<<" "<<tree[x].b<<" "<<tree[x].tag<<endl; if (tree[x].tag) { int mid=l+r>>1; tree[x].tag=0; tree[x<<1].tag=1; tree[x<<1|1].tag=1; tree[x<<1].a=(tree[x<<1].a+tree[x].a)%mo; tree[x<<1].b=(tree[x<<1].b+tree[x].b)%mo; tree[x<<1].sum=(tree[x<<1].sum+calc(tree[x].a,tree[x].b,mid-l+1))%mo; //cout<<"mid+1="<<mid+1<<endl; //cout<<tree[x<<1|1].a<<" "<< F(tree[x].a,tree[x].b,mid-l+2)<<endl; tree[x<<1|1].a=(tree[x<<1|1].a+F(tree[x].a,tree[x].b,mid-l+2))%mo; //cout<<tree[x<<1|1].b<<" "<< F(tree[x].a,tree[x].b,mid-l+3)<<endl; tree[x<<1|1].b=(tree[x<<1|1].b+F(tree[x].a,tree[x].b,mid-l+3))%mo; tree[x<<1|1].sum=(tree[x<<1|1].sum+calc(F(tree[x].a,tree[x].b,mid-l+2),F(tree[x].a,tree[x].b,mid-l+3),r-mid))%mo; tree[x].a=0,tree[x].b=0; tree[x].sum=tree[x<<1].sum+tree[x<<1|1].sum; //cout<<tree[x<<1|1].a<<" "<<tree[x<<1|1].b<<endl; } } void change(int x,int l,int r,int lq,int rq,int a,int b) { //printf("%d %d %d %d %d\n",x,l,r,a,b); if (lq<=l&&rq>=r) { tree[x].a=(tree[x].a+a)%mo; tree[x].b=(tree[x].b+b)%mo; tree[x].sum=(tree[x].sum+calc(a,b,r-l+1))%mo; tree[x].tag=1; return ; } int mid=l+r>>1; Pushdown(x,l,r); if (lq<=mid) change(x<<1,l,mid,lq,rq,a,b); if (rq>mid) { if (lq<=mid) change(x<<1|1,mid+1,r,lq,rq,F(a,b,mid-lq+2),F(a,b,mid-lq+3)); else change(x<<1|1,mid+1,r,lq,rq,a,b); } //if (mid-l+1>=2) tree[x].a=tree[x<<1].a,tree[x].b=tree[x<<1].b; //else tree[x].a=tree[x<<1].a,tree[x].b=tree[x<<1|1].a; tree[x].sum=tree[x<<1].sum+tree[x<<1|1].sum; //printf("l=%d r=%d sum=%d\n",l,r,tree[x].sum); } int query(int x,int l,int r,int lq,int rq) { //printf("[%d,%d] a=%d b=%d l=%d sum=%d\n",l,r,tree[x].a,tree[x].b,r-l+1,tree[x].sum); if (lq<=l&&rq>=r&&(l==r||!tree[x].tag)) return tree[x].sum; int mid=l+r>>1,res=0; Pushdown(x,l,r); if (lq<=mid) res=(res+query(x<<1,l,mid,lq,rq))%mo; if (rq>mid) res=(res+query(x<<1|1,mid+1,r,lq,rq))%mo; tree[x].sum=tree[x<<1].sum+tree[x<<1|1].sum; return res; } int main() { read(n);read(m); pre(); memset(a,0,sizeof(a)); for (int i=1;i<=n;i++) read(a[i]),a[i]=(a[i]+a[i-1])%mo; memset(tree,0,sizeof(tree)); int x,y,z; while(m--) { read(x),read(y),read(z); if (x==1) change(1,1,n,y,z,1,1); else //print((query(1,1,n,y,z))%mo),puts(""); print((query(1,1,n,y,z)+a[z]-a[y-1]+mo)%mo),puts(""); } return 0; } /* 50 80 161 254 648 762 509 898 67 189 622 567 604 32 652 964 427 466 580 817 599 752 598 476 908 7 783 167 1000 117 737 559 534 33 670 855 988 366 241 980 500 308 277 110 86 719 779 69 708 550 24 714 1 6 42 2 38 41 */ |
Categories: 未分类
1 Comment
Xiejiadong · 2018年11月1日 at 下午6:35
评论测试。