题意

给出一系列点,求这个多边形面积

思路

向量叉积

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream> using namespace std;
typedef long long LL; const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6; const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e2 + 5;
const int MOD = 1e9 + 7; struct Node
{
double x;
double y;
}G[maxn]; double Cross(Node a, Node b)
{
return a.x * b.y - a.y * b.x;
} int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
scanf("%lf%lf", &G[i].x, &G[i].y);
double sum = 0;
G[n].x = G[0].x;
G[n].y = G[0].y;
for (int i = 0; i < n; i++)
sum += Cross(G[i], G[i + 1]);
sum = sum / 2.0;
cout << sum << endl;
}
}

最新文章

  1. iOS开发的知名大牛博客小汇
  2. PHP配置参数
  3. grunt配置太复杂?使用Qbuild进行文件合并、压缩、格式化等处理
  4. zoj 3591 Nim 博弈论
  5. redis使用watch完成秒杀抢购功能:
  6. 鸟哥笔记:linux系统日志文件介绍
  7. C# Read/Write another Process&#39; Memory ZZ
  8. Nginx模块fastcgi_cache的几个注意点 转
  9. 解决&quot;the currently displayed page contains invalid values&quot;
  10. React 读书笔记
  11. java线程池的创建使用
  12. SQL Server统计信息偏差影响表联结方式案例浅析
  13. [转帖]golang操作mysql使用总结
  14. Java 调用Restful API接口的几种方式--HTTPS
  15. P1290 欧几里德的游戏
  16. Linux命令(十二) 分割文件 split 合并文件 join
  17. CentOS6下Jenkins连接Git服务器出错的问题
  18. pygame.error: Couldn&#39;t open images/ship.bmp
  19. iOS 开源库系列 Aspects核心源码分析---面向切面编程之疯狂的 Aspects
  20. 引子——从Mac OS X的Lion说起

热门文章

  1. 分布式服务框架 Zookeeper(三)官方入门指南
  2. 着手打造你的随身系统---将linux装进移动硬盘
  3. ffmpeg中的x264编码选项,对应关系
  4. Linux 文件管理(C语言库函数二--程序日志)
  5. WebMethod Session
  6. with root cause 解决办法
  7. Android-风格和主题
  8. 【转载】C#时间差的计算,精确输出“年月天时分秒”
  9. windows共享文件夹给centOS
  10. modelform 对象和model之间的关系