题目
思路
两边的平方和大于另一边 就是钝角三角形
代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long ll;
struct pp
{
ll x;
ll y;
}f[510];
int check(pp d,pp e,pp f)
{
ll a = labs(d.x - e.x)*labs(d.x - e.x) + labs(d.y - e.y)*labs(d.y - e.y);
ll b = labs(d.x - f.x)*labs(d.x - f.x) + labs(d.y - f.y)*labs(d.y - f.y);
ll c = labs(e.x - f.x)*labs(e.x - f.x) + labs(e.y - f.y)*labs(e.y - f.y);
if(sqrt(a)+sqrt(b)>sqrt(c) && sqrt(a)+sqrt(c)>sqrt(b) && sqrt(c)+sqrt(b)>sqrt(a))
{
if(a+b-c<0 || a+c-b<0 || b+c-a<0)
return 1;
else
return 0;
}
else
return 0;
}
int main()
{
int n;
cin>>n;
ll ans=0;
for(int i=1;i<=n;i++)
{
scanf("%lld %lld",&f[i].x,&f[i].y);
}
for(int i=1;i<=n-2;i++)
{
for(int j=i+1;j<=n-1;j++)
{
for(int k=j+1;k<=n;k++)
{
if(check(f[i],f[j],f[k]))ans++;
}
}
}
cout<<ans<<endl;
return 0;
}