【題解】AtCoder ABC 175B – Making Triangle

【題目敘述】https://atcoder.jp/contests/abc175/tasks/abc175_b

#include <iostream>
#include <set>
using namespace std;

int n, ans;
long long a[105];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        for (int j = 0; j < i; j++){
            if (a[j] == a[i]) continue;
            for (int k = 0; k < j; k++){
                if (a[k] == a[j] || a[k] == a[i]) continue;
                if (a[i] < a[j]+a[k] && a[j] < a[i]+a[k] && a[k] < a[i]+a[j]) ans++;
            }
        }
    }
    cout << ans << "\n";
}

分享本文 Share with friends