/* Consider a loop of string of unit length. Suppose we cut the string independently and at random in n places. This will divide the loop into n pieces. 1. What is the expected (average) size of the smallest piece? 2. What is the expected (average) size of the largest piece? */ #include #include #include #include #include #include #include #define M 50000 using namespace std; typedef vector vd; typedef ostream_iterator od; int main(int argc, char* argv[]) { srand(time(NULL)); double r; long j = 0; if (argc!=2) {return 1;} int N = atoi(argv[1]); cout.precision(10); cout << "Cut the loop string to " << N << " pieces ...\n"; vd randl, maxl, minl; od out(cout, " "); for (int i=0; i