记录编号 163353 评测结果 AAAAAAAAAA
题目名称 1361.树 最终得分 100
用户昵称 forever 是否通过 通过
代码语言 C++ 运行时间 0.594 s
提交时间 2015-05-24 06:53:37 内存使用 1.66 MiB
显示代码纯文本
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int n,a[200005],b[200005];
int temp,x,y,m;
inline int in(){
	char c=getchar();
	int x=0;
	while(c<'0'||c>'9')c=getchar();
	for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
	return x;
}

int lowbit(int j)
{
	return j&(-j);
}
void jianshu(int h,int hh)
{
	while(h<=n)
	{
		b[h]+=hh;
		h+=lowbit(h);
	}
	return;
}int sum(int h)
{
	int j=0;
	while(h>0)
	{
		j+=b[h];
		h-=lowbit(h);
	}
	return j;
}
int main()
{   freopen("treed.in","r",stdin);
	freopen("treed.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		temp=in();	
		a[i]=temp;
		jianshu(i,temp);
	
	}
	scanf("%d",&m);
	for(int i=1;i<=m;++i)
	{
		x=in();
		y=in();
		printf("%.2f\n",(sum(y)-sum(x-1))*3.14);
		int g=(x+y)>>1;
		jianshu(g,-a[g]);
		a[g]=0;
	}
	//system("pause");
}