溶液模拟器

武逸程  •  2年前


include

include

using namespace std; struct node{

int v;
double c;

}a[10005];

int main(void){

int n,top=1,v;
double c;
cin>>a[top].v>>a[top].c;
cin>>n;
for(int i=0;i<n;i++){
	char x;
	cin>>x;
	if(x=='Z'&&top>1){
		top--;
	}
	if(x=='P'){
		cin>>v>>c;
		top++;
		a[top].v=a[top-1].v+v;
		a[top].c=(v*c+a[top-1].v*a[top-1].c)/a[top].v;
	}
	printf("%d %.5lf\n",a[top].v,a[top].c);
}
return 0;

}


评论:

请先登录,才能进行评论