#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <ctime>
#include <cmath>
#include <bitset>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int maxn = 5002;
const int SIZE = 511111;
const double eps = 1e-10;
int a[maxn], b[maxn];
int main() {
ios::sync_with_stdio(false);
int n, i, T, cas;
scanf("%d",&T);
for (cas = 1; cas <= T; ++cas) {
scanf("%d", &n);
for (i = 0; i < n; ++i)
scanf("%d%d", a + i, b + i);
double x = n, y = 0;
for (i = n; i >= 1; --i)
y += n * 1.0 / i;
double delta = (y - x) / n;
double ans = 0;
for (i = 0; i < n; ++i) {
ans += a[i];
if (b[i] == 2)
ans += a[i] * delta;
}
printf("Case %d: %.10f\n",cas, ans);
}
return 0;
}
LightOJ 1342 - Aladdin and the Magical Sticks
最新推荐文章于 2021-10-26 18:25:47 发布