迪克撸迪克78吃78卍卐邱博宇 • 2个月前
using namespace std;
struct node {
int v;
double c;
}; node a[N];
int main(void) {
int n, top = 1;
char ch;
cin >> a[top].v >> a[top].c >> n;
while (n--) {
cin >> ch;
if (ch == 'Z' && top > 1) {
top--;
}
if (ch == 'P') {
top++;
cin >> a[top].v >> a[top].c;
a[top].v = a[top - 1].v + a[top].v;
a[top].c = (a[top - 1].c * a[top - 1].v + (a[top].v - a[top - 1].v) * a[top].c) / a[top].v;
}
printf("%d %.5lf\n", a[top].v, a[top].c);
}
return 0;
}
评论:
请先登录,才能进行评论