#include #include #include #include #include using namespace std; vector aa; vector bb; vector cc; vector dd; int n; typedef pair t_pos; t_pos cross(double a, double b, double c, double d) { double ky = (a + (b-a)*c) / (1 - (b-a)*(d-c)); double y = ky; double x = c + (d-c) * ky; assert(ky >= 0); assert(0 <= x && x <= 1.0); assert(0 <= y && y <= 1.0); return make_pair(x, y); } double surface_3(t_pos& p1, t_pos& p2, t_pos& p3){ t_pos v1 = make_pair(p2.first-p1.first, p2.second-p1.second); t_pos v2 = make_pair(p3.first-p1.first, p3.second-p1.second); double len1 = sqrt(v1.first*v1.first + v1.second*v1.second); double len2 = sqrt(v2.first*v2.first + v2.second*v2.second); assert(len1 > 0.0); assert(len2 > 0.0); double dot = (v1.first * v2.first + v1.second * v2.second); double cosA = dot / (len1*len2); double sinA = sqrt(1.0 - cosA * cosA); double s = len1 * len2 * sinA / 2.0; assert(s > 0); // cout << "base:" << base << ", naname:" << naname << " sur:" << s << endl; return s; } double surface_4(t_pos& p1, t_pos& p2, t_pos& p3, t_pos& p4){ return surface_3(p1, p2, p4) + surface_3(p1, p3, p4); } double surface(int i, int j){ double b1 = bb[i]; double b2 = bb[i+1]; double a1 = aa[i]; double a2 = aa[i+1]; double c1 = cc[j]; double c2 = cc[j+1]; double d1 = dd[j]; double d2 = dd[j+1]; double surface; t_pos p1, p2, p3, p4; p1 = cross(a1, b1, c1, d1); p2 = cross(a2, b2, c1, d1); p3 = cross(a1, b1, c2, d2); p4 = cross(a2, b2, c2, d2); // printf("cross at (%f,%f)\n", p1.first, p1.second); double s = surface_4(p1, p2, p3, p4); //cout << s << endl; return s; } int main(){ while (cin >> n){ if (n == 0) break; aa.resize(n+2); bb.resize(n+2); cc.resize(n+2); dd.resize(n+2); aa[0] = 0.0; bb[0] = 0.0; cc[0] = 0.0; dd[0] = 0.0; for (int i=0; i> aa[i+1]; for (int i=0; i> bb[i+1]; for (int i=0; i> cc[i+1]; for (int i=0; i> dd[i+1]; aa[n+1] = 1.0; bb[n+1] = 1.0; cc[n+1] = 1.0; dd[n+1] = 1.0; double max_surface = 0.0; double total = 0.0; for (int i=0; i<=n; ++i){ for (int j=0; j<=n; ++j){ double s = surface(i, j); // printf("surf at (%d, %d) is %f\n", i, j, s); total += s; max_surface = max(max_surface, s); } } printf("%.6f\n", max_surface); } return 0; }