Topic links
Double the Experience problem
Same as:bzoj3038
Only the subject must open long long
1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharCh=GetChar (); in while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} - while(ch>='0'&&ch<='9') ret*=Ten, ret+=ch-'0', ch=GetChar (); toret=f?-Ret:ret; + } -LL sum[400010]; the intl[400010],r[400010],bo[400040]; * intn,m,a[100010]; $ voidBuildintKintllintRR)Panax Notoginseng { -l[k]=ll,r[k]=RR; the if(LL==RR) {SUM[K]=A[LL];if(sum[k]==0|| sum[k]==1) bo[k]=1;return ;} + intMid= (LL+RR) >>1; ABuild (k<<1, ll,mid); theBuild (k<<1|1, mid+1, RR); +sum[k]=sum[k<<1]+sum[k<<1|1],bo[k]=bo[k<<1]&bo[k<<1|1]; - } $LL Query (intKintllintRR) $ { - if(L[K]>=LL&&R[K]<=RR)returnSum[k]; - intMid= (L[k]+r[k]) >>1; the if(Rr<=mid)returnQuery (k<<1, LL,RR); - if(Ll>mid)returnQuery (k<<1|1, LL,RR);Wuyi returnQuery (k<<1, LL,RR) +query (k<<1|1, LL,RR); the } - voidChangeintKintllintRR) Wu { - if(Bo[k])return ; About if(L[k]==r[k]) {sum[k]=sqrt (sum[k]);if(sum[k]==0|| sum[k]==1) bo[k]=1;return ;} $ intMid= (L[k]+r[k]) >>1; - if(rr<=mid) Change (k<<1, LL,RR); - Else if(ll>mid) Change (k<<1|1, LL,RR); - ElseChange (k<<1, LL,RR), Change (k<<1|1, LL,RR); Asum[k]=sum[k<<1]+sum[k<<1|1],bo[k]=bo[k<<1]&bo[k<<1|1]; + } the intCSC () - { $ inin (n); theRe (I,1, N) inin (a[i]); theBuild1,1, n); the Inin (m); theRe (I,1, M) - { in intOpt,aa,bb;inin (opt), Inin (AA), Inin (BB); the if(opt==1) printf ("%lld\n", Query (1, AA,BB)); the ElseChange1, AA,BB); About } the return 0; the}
bzoj3211 the world of flowers and Gods