#include int main(void) { int P; int x, y, px, py, fx, fy; int L; scanf("%d", &P); while(P) { scanf("%d %d",&fx, &fy); P--; if(P == 0) { printf("The length of the fence will be 0 units.\n"); scanf("%d", &P); continue; } px = fx; py = fy; L = 0; while(P) { scanf("%d %d", &x, &y); P--; if(x == px) { L += (py > y) ? py-y : y-py; } else { L += (px > x) ? px-x : x-px; } px = x; py = y; } if(x == fx) { L += (fy > y) ? fy - y : y - fy; } else { L += (fx > x) ? fx - x : x - fx; } printf("The length of the fence will be %d units.\n", L); scanf("%d", &P); } return 0; }