[tsA1490] [2013 China National Training Team second Operation]osu! [Probability dp+ segment tree + matrix multiplication]

Source: Internet
Author: User

Such a puzzle can only be licked,,, Qaq

There are in the clear orange data.

1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <cmath>6#include <ctime>7#include <algorithm>8 9 using namespacestd;Ten  One structMatrix A { -     Doublea,b,c,d; - }; the  - structnode - { -     Doubles0,s1; + Matrix S2; -}tree[2100000]; +  A Doublea[510000]; at  - voidPUSH_UP (Const intNumConst intPOS) - { -Node &temp1=tree[num<<1],&temp2=tree[num<<1|1]; -Tree[num]. S0=temp1. S0+temp2. s0-a[pos]*a[pos+1]; -Tree[num]. S1=temp1. s1+Temp2. S1; inMatrix T1=TEMP1. S2,t2=Temp2. S2; -Tree[num]. S2= (Matrix) {t1.a*t2.a,t1.a*t2.b+t1.b,t1.c*t2.a+t2.c,t1.c*t2.b+t1.d+t2.d}; to     return ; + } -  the voidChange (Const intLConst intRConst intNumConst intSConstnode D) * { $     if(l==R)Panax Notoginseng     { -a[l]=D.s0; thetree[num]=D; +         return ; A     } the  +     intmid=l+ (r-l) >>1); -  $     if(S<=mid) Change (l,mid,num<<1, s,d); $     ElseChange (mid+1,r,num<<1|1, s,d); -  - push_up (num,mid); the     return ; - }Wuyi  theNode Calc (ConstNode Temp1,ConstNode Temp2,Const intPOS) - { Wu node A; -  AboutA.s0=temp1. S0+temp2. s0-a[pos]*a[pos+1]; $A.s1=temp1. s1+Temp2. S1; -  -Matrix T1=TEMP1. S2,t2=Temp2. S2; -A.s2= (Matrix) {t1.a*t2.a,t1.a*t2.b+t1.b,t1.c*t2.a+t2.c,t1.c*t2.b+t1.d+t2.d}; A  +     returnA; the } -  $Node Query (Const intLConst intRConst intNumConst intSConst intt) the { the     if(S<=l && r<=t) the         returnTree[num]; the  -     intmid=l+ (r-l) >>1); in  the     if(T<=mid)returnQuery (l,mid,num<<1, s,t); the     if(S>mid)returnQuery (mid+1,r,num<<1|1, s,t); About     returnCalc (Query (l,mid,num<<1, s,t), Query (mid+1,r,num<<1|1, S,t), mid); the } the  the intMain () + { -     intN,m,i,op; the Bayiscanf"%d%d",&n,&m); the  the      for(i=1; i<=n;++i) -scanf"%LF",&a[i]); -      for(i=1; i<=n;++i) theChange (1N1, I, (node) {A[i],a[i], (Matrix) {a[i],a[i]*2, A[i],a[i]}}); the  the      for(i=1; i<=m;++i) the     { -scanf"%d",&op); the          the         if(op==0) the         {94             intx, y; thescanf"%d%d",&x,&y); the  theNode Temp=query (1N1, x, y);98printf"%.2f\n", temp. S0+temp. s1+temp. S2.D); About         } - 101         if(op==1)102         {103             intx;104             Doubley; the 106scanf"%D%LF",&x,&y);107Change (1N1, X, (node) {y,y, (Matrix) {y,y*2, Y,y}});108         }109     } the     return 0;111}

[tsA1490] [2013 China National Training Team second Operation]osu! [Probability dp+ segment tree + matrix multiplication]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.