#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

P projection(const L& l, const P& p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}

bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}
double getarea(const VP &poly){
    int n = poly.size();
    double ret = 0;
    for (int i=0; i<n; i++){ 
        ret += cross(poly[i], poly[(i+1)%n]);
    }
    return ret*0.5;
}

double solve(const VP& poly){
    int n = poly.size();
    double ret = 0;
    vector<L> cand;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            cand.emplace_back(poly[i], poly[j]);
        }
        for(int j=0; j<n; j++){
            L edge(poly[j], poly[(j+1)%n]);
            if(distanceLP(edge, poly[i]) > EPS){
                cand.emplace_back(poly[i], projection(edge, poly[i]));
            }
        }
    }

    for(L &line: cand){
        VP plist;
        for(int k=0; k<n; k++){
            L edge(poly[k], poly[(k+1)%n]);
            if(!isParallel(line, edge) && intersectLS(line, edge)){
                plist.push_back(crosspointLL(line, edge));
            }
        }
        sort(plist.begin(), plist.end());
        plist.erase(unique(plist.begin(), plist.end()), plist.end());
        
        plist.emplace_back(INF, 0);
        double range = 0;
        for(int i=0; i<(int)plist.size()-1; i++){
            if(in_poly((plist[i] +plist[i+1]) /2.0, poly) >= 0){
                range += abs(plist[i+1] -plist[i]);
            }else{
                ret = max(ret, range);
                range = 0;
            }
        }
    }
    return ret;
}

int main(){
    int dn=0;
    while(1){
        dn++;
        int n;
        cin >> n;
        if(n == 0) break;

        VP p(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        cout << fixed << setprecision(10);
        cout << "Case " << dn << ": " << solve(p) << endl;
        
    }
    return 0;
}

### Prompt

Please formulate a Cpp solution to the following problem:

Mr. KM, the mayor of KM city, decided to build a new elementary school. The site for the school has an awkward polygonal shape, which caused several problems. The most serious problem was that there was not enough space for a short distance racetrack. Your task is to help Mr. KM to calculate the maximum possible length for the racetrack that can be built in the site. The track can be considered as a straight line segment whose width can be ignored. The boundary of the site has a simple polygonal shape without self-intersection, and the track can touch the boundary. Note that the boundary might not be convex.



Input

The input consists of multiple test cases, followed by a line containing "0". Each test case has the following format. The first line contains an integer N (3 \leq N \leq 100). Each of the following N lines contains two integers x_i and y_i (-1,000 \leq x_i, y_i \leq 1,000), which describe the coordinates of a vertex of the polygonal border of the site, in counterclockwise order.

Output

For each test case, print its case number and the maximum possible length of the track in a line. The answer should be given as a floating point number with an absolute error of at most 10^{-6}.

Example

Input

4
0 0
10 0
10 10
0 10
3
0 0
1 0
0 1
0


Output

Case 1: 14.142135624
Case 2: 1.41421356

### Response

```cpp
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return !EQ(a.X,b.X) ? a.X<b.X : a.Y+EPS<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

P projection(const L& l, const P& p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}

bool intersectLS(const L& l, const L& s){
    return cross(l[1]-l[0], s[0]-l[0])*
        cross(l[1]-l[0], s[1]-l[0]) < EPS;
}
bool intersectSP(const L& s, const P &p){
    return abs(cross(s[0]-p, s[1]-p))<EPS  && dot(s[0]-p, s[1]-p)<EPS;
}

bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

int in_poly(const P &p, const VP &poly){
    int n = poly.size();
    int ret = -1;
    for(int i=0; i<n; i++){
        P a = poly[i]-p;
        P b = poly[(i+1)%n]-p;
        if(a.Y > b.Y) swap(a,b);
        if(intersectSP(L(a,b), P(0,0))) return 0;
        if(a.Y<=0 && b.Y>0 && cross(a,b)<0) ret = -ret;
    }
    return ret;
}
double getarea(const VP &poly){
    int n = poly.size();
    double ret = 0;
    for (int i=0; i<n; i++){ 
        ret += cross(poly[i], poly[(i+1)%n]);
    }
    return ret*0.5;
}

double solve(const VP& poly){
    int n = poly.size();
    double ret = 0;
    vector<L> cand;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            cand.emplace_back(poly[i], poly[j]);
        }
        for(int j=0; j<n; j++){
            L edge(poly[j], poly[(j+1)%n]);
            if(distanceLP(edge, poly[i]) > EPS){
                cand.emplace_back(poly[i], projection(edge, poly[i]));
            }
        }
    }

    for(L &line: cand){
        VP plist;
        for(int k=0; k<n; k++){
            L edge(poly[k], poly[(k+1)%n]);
            if(!isParallel(line, edge) && intersectLS(line, edge)){
                plist.push_back(crosspointLL(line, edge));
            }
        }
        sort(plist.begin(), plist.end());
        plist.erase(unique(plist.begin(), plist.end()), plist.end());
        
        plist.emplace_back(INF, 0);
        double range = 0;
        for(int i=0; i<(int)plist.size()-1; i++){
            if(in_poly((plist[i] +plist[i+1]) /2.0, poly) >= 0){
                range += abs(plist[i+1] -plist[i]);
            }else{
                ret = max(ret, range);
                range = 0;
            }
        }
    }
    return ret;
}

int main(){
    int dn=0;
    while(1){
        dn++;
        int n;
        cin >> n;
        if(n == 0) break;

        VP p(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            p[i] = P(x, y);
        }
        cout << fixed << setprecision(10);
        cout << "Case " << dn << ": " << solve(p) << endl;
        
    }
    return 0;
}

```