コード例 #1
0
ファイル: miniball.cpp プロジェクト: X-Wei/ETH-Algolab-FS2015
int main()
{
  const int n = 100;
  K::Point_2 P[n];
  
  for (int i = 0; i < n; ++i)
    P[i] = K::Point_2((i % 2 == 0 ? i : -i), 0);
  // (0,0), (-1,0), (2,0), (-3,0), ...
  
  Min_circle mc(P, P+n, true);
  Traits::Circle c = mc.circle();
  std::cout << c.center() << " " << c.squared_radius() << std::endl;
}
コード例 #2
0
ファイル: antenna.cpp プロジェクト: cassiesu/algorithms_lab
int main()
{
    while(cin >> n && n > 0)
    {
        for(int i=0;i<n;i++)
        {
            cin >> a >> b;
            p[i] = P(a,b);
        }
        Min_circle mc(p,p+n,true);
        Traits::Circle c = mc.circle();        
        cout << setiosflags(ios::fixed) << setprecision(0);
        d = sqrt(c.squared_radius());
        t=to_double(d);
        cout << ceil_to_double(d) << endl;
    }
    return 0;
}
コード例 #3
0
ファイル: almostantenna.cpp プロジェクト: foxymoron/algolab
int main() {
    int n; cin >> n;

    while(n != 0) {
        vector<P> points;
        for(int i=0; i<n; ++i) {
            double x, y; cin >> x >> y; // have to
            P p(x, y);
            points.push_back(p);
        }

        random_shuffle(points.begin(), points.end());

        Min_circle mc(points.begin(), points.end(), true);
        Traits::Circle c = mc.circle();

        double min_radius = ceil_to_double(sqrt(c.squared_radius()));
        for(spi it = mc.support_points_begin(); it != mc.support_points_end(); ++it) {
            vector<P> points_copy = points;
            points_copy.erase(remove(points_copy.begin(), points_copy.end(), *it), points_copy.end());

            random_shuffle(points_copy.begin(), points_copy.end());
            Min_circle mc2(points_copy.begin(), points_copy.end(), true);
            Traits::Circle c2 = mc2.circle();

            double radius = ceil_to_double(sqrt(c2.squared_radius()));
            if(radius < min_radius)
                min_radius = radius;
        }


        cout << std::setiosflags(std::ios::fixed) << 
            std::setprecision(0) <<
            min_radius << endl;

        cin >> n;
    }
    return 0;
}