zoukankan      html  css  js  c++  java
  • Good Bye 2020 A

    Good Bye 2020 A

    大意

    (OXY) 二维平面上,有一个点 ((0,1)) ,现在给定 (N) 个值 (x_1,x_2,...,x_n) 代表了 (N) 个点,坐标为 ((x_1,0), (x_2,0),..., (x_n,0))

    问,有多少种三角形面积可以被构成。

    思路

    因为给定点的坐标都在 (X) 轴上,仅有一个初始点在 ((0,1)) 所以三角形面积的种类数就是底边长的种类数。

    (Theta(n^2)) 暴力跑一边。

    代码

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    using namespace std;
    
    #define ll long long
    #define ull unsigned long long
    #define cint const int&
    #define Pi acos(-1)
    
    const int mod = 998244353;
    const int inf_int = 0x7fffffff;
    const ll inf_ll = 0x7fffffffffffffff;
    const double ept = 1e-9;
    
    int t;
    int n;
    int a[51];
    bool dp[101];
    
    int main() {
        cin >> t;
        while(t--) {
            memset(dp, 0, sizeof dp);
            dp[0] = 1;
            int ans=0;
            cin >> n;
            for(int i=1; i<=n; i++) cin >> a[i];
            sort(a+1, a+1+n);
            for(int i=1; i<=n; i++)
                for(int j=i-1; j; j--)
                    if(!dp[a[i]-a[j]]) {
                        dp[a[i]-a[j]] = 1;
                        ++ans;
                    }
            cout << ans << endl;
        }
        return 0;
    }
    

    7min,-0

  • 相关阅读:
    纪念又一次ak
    hdu5618
    bzoj3393
    bzoj3438
    [JSOI2007]建筑抢修
    [CQOI2014]数三角形
    [BZOJ2662][BeiJing wc2012]冻结
    [NOIP2015]运输计划
    [ZJOI2006]超级麻将
    [APIO2009]抢掠计划
  • 原文地址:https://www.cnblogs.com/ullio/p/14215885.html
Copyright © 2011-2022 走看看