#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int N, A, B, slices, stacks;
int coef[100], sq_coef[100];
double ind_coef[100];
double power_(double x, int y) {
double ans = 1;
for (int i = 0; i < y; i++)
ans *= x;
return ans;
}
void square_pol() {
memset(sq_coef, 0, sizeof(sq_coef));
for (int i = 0; i <= N; i++) {
for (int k = 0; k <= N; k++) {
int c = i + k;
sq_coef[c] += coef[i] * coef[k];
}
}
}
double evaluate(double x) {
double ans = 0;
for (int i = 0; i <= N; i++) {
ans += coef[i] * power_(x, i);
}
return ans;
}
double indefinite_evaluate(double x) {
double ans = 0;
for (int i = 0; i <= 2*N + 1; i++) {
ans += ind_coef[i] * power_(x, i);
}
return ans;
}
void indefinite_integral() {
for (int i = 2*N + 1; i > 0; i--) {
ind_coef[i] = sq_coef[i-1]*1.0 / (i);
}
}
double definite_integral() {
square_pol();
indefinite_integral();
return PI * (indefinite_evaluate(B) - indefinite_evaluate(A));
}
double approximate() {
double theta = 2*PI / slices;
double width = (B - A)* (1.0) / stacks * 1.0;
double volume = 0;
double start_ = A, end_ = A + width;
for (int i = 0; i < stacks; i++) {
double px1 = evaluate(start_);
double px2 = evaluate(end_);
double m = (px2 - px1) / (end_ - start_);
double c = px2 - m * end_;
volume += (end_ - start_) * c * c;
volume += m * c * (end_ * end_ - start_ * start_);
volume += m * m * (end_*end_*end_ - start_*start_*start_) / 3;
start_ += width;
end_ += width;
}
return volume * sin(theta) / 2;
}
int main() {
int T; cin >> T;
for (int t = 0; t < T; t++) {
cin >> N;
for (int i = N; i >= 0; i--) {
cin >> coef[i];
}
cin >> A >> B;
cin >> slices >> stacks;
double real_volume = definite_integral();
double app_volume = approximate() * slices;
cout << "Case " << t + 1 << ": ";
cout << fixed << setprecision(4);
cout << fabs((real_volume - app_volume) / real_volume) * 100.0 << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBsb25nIGRvdWJsZSBQSSA9IGFjb3MoLTEpOwppbnQgTiwgQSwgQiwgc2xpY2VzLCBzdGFja3M7CmludCBjb2VmWzEwMF0sIHNxX2NvZWZbMTAwXTsKZG91YmxlIGluZF9jb2VmWzEwMF07Cgpkb3VibGUgcG93ZXJfKGRvdWJsZSB4LCBpbnQgeSkgewogICAgZG91YmxlIGFucyA9IDE7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IHk7IGkrKykKICAgICAgICBhbnMgKj0geDsKICAgIHJldHVybiBhbnM7Cn0KCnZvaWQgc3F1YXJlX3BvbCgpIHsKICAgIG1lbXNldChzcV9jb2VmLCAwLCBzaXplb2Yoc3FfY29lZikpOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IE47IGkrKykgewogICAgICAgIGZvciAoaW50IGsgPSAwOyBrIDw9IE47IGsrKykgewogICAgICAgICAgICBpbnQgYyA9IGkgKyBrOwogICAgICAgICAgICBzcV9jb2VmW2NdICs9IGNvZWZbaV0gKiBjb2VmW2tdOwogICAgICAgIH0KICAgIH0KfQoKZG91YmxlIGV2YWx1YXRlKGRvdWJsZSB4KSB7CiAgICBkb3VibGUgYW5zID0gMDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDw9IE47IGkrKykgewogICAgICAgIGFucyArPSBjb2VmW2ldICogcG93ZXJfKHgsIGkpOwogICAgfQogICAgcmV0dXJuIGFuczsKfQoKZG91YmxlIGluZGVmaW5pdGVfZXZhbHVhdGUoZG91YmxlIHgpIHsKICAgIGRvdWJsZSBhbnMgPSAwOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gMipOICsgMTsgaSsrKSB7CiAgICAgICAgYW5zICs9IGluZF9jb2VmW2ldICogcG93ZXJfKHgsIGkpOwogICAgfQogICAgcmV0dXJuIGFuczsKfQoKdm9pZCBpbmRlZmluaXRlX2ludGVncmFsKCkgewogICAgZm9yIChpbnQgaSA9IDIqTiArIDE7IGkgPiAwOyBpLS0pIHsKICAgICAgICBpbmRfY29lZlt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