[POI2008]Tro

Time Limit: 20 Sec  Memory Limit: 162 MB
Submit: 1796  Solved: 604
[Submit][Status][Discuss]

Description

平面上有N个点. 求出所有以这N个点为顶点的三角形的面积和 N<=3000

Input

第一行给出数字N,N在[3,3000] 下面N行给出N个点的坐标,其值在[0,10000]

Output

保留一位小数,误差不超过0.1

Sample Input

5
0 0
1 2
0 2
1 0
1 1

Sample Output

7.0

HINT

枚举起点,然后求出以该点为起点的所有向量,然后求面积就可以了。

 #include<cstring>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm> #define N 3007
#define ll long long
using namespace std;
inline int read()
{
int x=,f=;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-;ch=getchar();}
while(isdigit(ch)){x=(x<<)+(x<<)+ch-'';ch=getchar();}
return x*f;
} int n;ll ans;
struct Node
{
int x,y;
friend inline ll operator*(Node x,Node y)
{
return x.x*y.y-x.y*y.x;
}
friend inline bool operator<(Node x,Node y)
{
if (x.y==y.y) return x.x<y.x;
return x.y<y.y;
}
}a[N],b[N];
bool cmp(Node x,Node y)
{
return x*y>;
} void solve()
{
sort(a+,a+n+);
for (int i=;i<=n-;i++)
{
int tot=;ll sumx=,sumy=;
for (int j=i+;j<=n;j++)
b[++tot].x=a[j].x-a[i].x,
b[tot].y=a[j].y-a[i].y;
sort(b+,b+tot+,cmp);
for (int j=;j<=tot;j++)
sumx+=b[j].x,
sumy+=b[j].y;
for (int j=;j<=tot;j++)
{
sumx-=b[j].x;
sumy-=b[j].y;
ans+=(ll)b[j].x*sumy-b[j].y*sumx;
}
}
}
int main()
{
n=read();
for (int i=;i<=n;i++)
a[i].x=read(),a[i].y=read();
solve();
if (ans&) printf("%lld.5",ans/);
else printf("%lld.0",ans/);
}
#undef ll

最新文章

  1. OpenCASCADE Make Primitives-Sphere
  2. Java内存模型深度解析:基础部分--转
  3. PS如何查找自己想要的字体
  4. Moving in Unity
  5. AIX 下某些日志定时清空
  6. unity3d实现序列帧动画
  7. Mysql创建函数出错
  8. 解决获取IP地址时出现“在一个非套…
  9. xhost
  10. 机器学习笔记(一)- from Andrew Ng的教学视频
  11. webstorm常用快捷键及(idea,phpstorm,android studio通用)使用技巧
  12. winform - json串的转换
  13. 19,CSS 滤镜
  14. js模块化世界
  15. 【scarletthln 关于算法的一点总结】
  16. 企业级镜像仓库Harbor
  17. golang sync.Cond条件变量的使用
  18. 【Java算法】输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数
  19. apache代理weblogic集群办法
  20. MySQL 存储过程 -流程控制的使用

热门文章

  1. docker最佳实践-----美团点评的分享
  2. Python中的相对导入语法
  3. 20145214 《Java程序设计》第4周学习总结
  4. TensorFlow源码框架 杂记
  5. Unity3d学习日记(二)
  6. 微信小程序wx.pageScrollTo的替代方案
  7. AutoResetEvent的基本用法
  8. MySQL event调度
  9. pyHeatMap生成热力图
  10. wpf拖拽