大力猜结论:所有位于定义域内的数的取值的概率都相等,所以答案就是平均数。
ref
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <iostream> #include <cstdio> using namespace std; typedef long long ll; int n, r, a[262155], uu, vv; ll sum; int main(){ cin>>n>>r; for(int i=0; i<(1<<n); i++){ scanf("%d", &a[i]); sum += a[i]; } printf("%.12f\n", (double)sum/(1<<n)); while(r--){ scanf("%d %d", &uu, &vv); sum -= a[uu]; a[uu] = vv; sum += a[uu]; printf("%.12f\n", (double)sum/(1<<n)); } return 0; }
|