zoukankan      html  css  js  c++  java
  • HDU2202 最大三角形 计算几何 凸包

    给出n给点,求出最大的三角形的面积

    有用的点只有凸包上的点,因此只需枚举凸包上的点即可

    数据比较简单,暴力即可

    #include<iostream>
    #include<unordered_map>
    #include<algorithm>
    #include<string>
    #include<cmath>
    #include<cstring>
    #include<vector>
    #include<map>
    #include<set>
    #include<queue>
    #include<deque>
    #include<stack>
    #include<sstream>
    #include <cstdlib>
    #include<cstdio>
    #include<random>
    #define INF 0x3f3f3f3f
    #define eps 1e-8
    #define equals(a,b) (fabs(a-b)<eps)
    #define MOD 100000007
    std::mt19937 rnd(233);
    //#define rnd() rand()%1000
    const int maxn = 5e5+5 ;
    const double PI = acos(-1.0);
    typedef long long ll;
    using namespace std;
    
    struct Point {
        ll x;
        ll y;
        Point(ll x = 0, ll y = 0) :x(x), y(y) {}
        friend bool operator < (const Point& a, const Point& b) {
            if (a.x != b.x) return a.x < b.x;
            else return a.y < b.y;
        }
    };
    
    set<Point> v;
    
    int main() {
        int T;
        int n, a1, b1, c1, a2, b2, c2;
        scanf("%d", &T);
        while (T--) {
            v.clear();
            scanf("%d%d%d%d%d%d%d", &n, &a1, &b1, &c1, &a2, &b2, &c2);
            ll x, y, sum, mids;
            x = y = sum = 0;
            mids = (1ll<<60)-1;
            for (int i = 0; i < n; i++) {
                x = (x * a1 + b1) % c1;
                y = (y * a2 + b2) % c2;
                Point p;
                p.x = x, p.y = y;
                if (!v.count(p)) {
                    if (i > 0) {
                        auto it = v.lower_bound(p);
                        for (auto e = it; e != v.end(); e++) {
                            int next_x = e->x - p.x;
                            if (next_x * next_x > mids) break;
                            int next_y = e->y - p.y;
                            ll dis = (ll)next_x * next_x + (ll)next_y * next_y;
                            mids = min(mids, dis);
                        }
                        for (auto e = it; e != v.begin(); ) {
                            e--;
                            int next_x = e->x - p.x;
                            if (next_x * next_x > mids) break;
                            int next_y = e->y - p.y;
                            ll dis = (ll)next_x * next_x + (ll)next_y * next_y;
                            mids = min(dis, mids);
                        }
                        sum += mids;
                    }
                    v.insert(Point(x, y));
                }
                else break;
            }
            printf("%lld\n", sum);
        }
        return 0;
    }
  • 相关阅读:
    linux查看CPU性能及工作状态的指令mpstat,vmstat,iostat,sar,top
    Linux vmstat命令实战详解
    dstat 性能监测工具
    sysstat 工具
    Linux命令详解----iostat
    Linux CPU实时监控mpstat命令详解
    Linux Top 命令解析 比较详细
    Linux统计/监控工具SAR详细介绍
    ubuntu 添加用户到已存在的组
    Ubuntu 14.04 使用速度极快的Genymotion 取代蜗牛速度的原生AVD模拟器
  • 原文地址:https://www.cnblogs.com/hznumqf/p/12607696.html
Copyright © 2011-2022 走看看