标签:span nbsp i++ else long main pre turn for
1 #include<cstdio> 2 int a[100000]; 3 long long tree[100000]; 4 void createtree(int i,int value,int n,long long tree[]) 5 { 6 while(i<=n) 7 { 8 tree[i]=tree[i]+value; 9 i=i+(i&-i); 10 } 11 } 12 long long getsum(int x,long long tree[]) 13 { 14 long long sum = 0; 15 for(int i=x;i>0;i=i-(i&-i)) 16 sum += tree[i]; 17 return sum; 18 } 19 int main() 20 { 21 int n; 22 int m; 23 int opt; 24 int l,r; 25 int v; 26 scanf("%d%d",&n,&m); 27 for(int i=1;i<=n;i++) 28 { 29 scanf("%d",&a[i]); 30 createtree(i,a[i],n,tree); 31 } 32 while(m--) 33 { 34 scanf("%d",&opt); 35 { 36 if(opt==1) 37 { 38 scanf("%d%d%d",&l,&r,&v); 39 if(v==1) 40 continue; 41 while(l<=r) 42 { 43 if(a[l]>=v&&a[l]%v==0) 44 { 45 createtree(l,a[l]/v-a[l],n,tree); 46 a[l] = a[l] / v; 47 } 48 l++; 49 } 50 } 51 else 52 { 53 scanf("%d%d",&l,&r); 54 printf("%lld\n",getsum(r,tree)-getsum(l-1,tree)); 55 } 56 } 57 } 58 return 0; 59 }
标签:span nbsp i++ else long main pre turn for
原文地址:http://www.cnblogs.com/zhuyisanguan/p/7944673.html