嘟嘟嘟

题意:按逆时针或顺时针给出一个多边形,求面积。

解法:直接套用公式:\(S = \frac{1}{2}|\sum _ {i = 1} ^ {n} {v_i \times v_{i + 1}}|\)




别忘了POJ实数输出的时候必须%\(f\),不能%\(lf\)……

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define rg register
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
const int maxn = 1e3 + 5;
inline ll read()
{
ll ans = 0;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) last = ch, ch = getchar();
while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
if(last == '-') ans = -ans;
return ans;
}
inline void write(ll x)
{
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
} int n;
struct Vec
{
db x, y;
db operator * (const Vec& oth)const
{
return x * oth.y - oth.x * y;
}
}a[maxn]; db area()
{
a[n + 1] = a[1];
db ans = 0;
for(int i = 1; i <= n; ++i) ans += a[i] * a[i + 1];
ans = ans < -eps ? -ans : ans;
return ans / 2.00;
} int main()
{
while(scanf("%d", &n) && n)
{
for(int i = 1; i <= n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
printf("%.0f\n", area());
}
return 0;
}

POJ3907 Build Your Home的更多相关文章

  1. POJ3907:Build Your Home——题解

    http://poj.org/problem?id=3907 题目大意:求多边形面积,结果四舍五入. ———————————————————— 多边形面积公式板子题. #include<cstd ...

  2. 解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用

    问题: Springboot启动报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ...

  3. [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform

    eclipse maven clean install 报错 1. 修改properties-->resource-->utf-8仍然报错 2.修改项目pom.xml文件,增加: < ...

  4. 解决 Could not find com.android.tools.build:gradle 问题

    今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...

  5. 搭建TFS 2015 Build Agent环境(一)

    Download the build agent Downloading the build agent is really simple. Navigate to your TFS control ...

  6. Go build constraints

    Go语言有一个不(奇)错(葩)的设计,就是build constraints(构建约束).可以在源码中通过注释的方式指定编译选项,比如只允许在linux下,或者在386的平台上编译啊之类的:还可以通过 ...

  7. [异常解决] How to build a gcc toolchain for nRF51 on linux (very detailed!!!)

    1.Install gcc-arm-none-eabi https://devzone.nordicsemi.com/tutorials/7/This link shows that developm ...

  8. Microsoft Build 2016 Day 2 记录(多图慎入)

    Microsoft Build 2016 Day 1 记录 Microsoft Build 2016 进行到了第二天,我觉得这一天的内容非常精彩,因为主要和开发者相关

  9. Microsoft Build 2016 Day 1 记录

    去年今日:Microsoft Build 2015 汇总 今年的 Bulid 时间是 3.30-4.1,第一天的主角主要是 Windows 10.人工智能.HoloLens.小娜等,详细介绍:3 分钟 ...

随机推荐

  1. ASP.NET 简单的柱形图实现(附带示例)

    对于一些内部系统的项目,各种图表是在所难免的,因为图表可以更加清晰的表达出想看到的数据. 因为之前从来没有做过关于图表的东西,唯一能想到的就是“验证码”,所以应该是一个思路,用GDI去搞. 数据懒着去 ...

  2. 六、阻塞队列LinkedBlockQueue

    一.简介 Java提供了FIFO先进先出的阻塞队列实现,这其实是一种生产者消费者理念,可以通过阻塞队列将生产者和消费者进行解耦合. LinkedBlockQueue是一种无界队列,但事实上它只是队列可 ...

  3. [LeetCode]Generate Parentheses题解

    Generate Parentheses: Given n pairs of parentheses, write a function to generate all combinations of ...

  4. HDU 1575 Tr A----矩阵相乘题。

    Tr A Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

  5. jenkins在Linux 下安装部署

      这里介绍两种方法,一种方法将最新版jenkins加入到yum源,另外一种是下载指定版本的rpm包 系统centos6 自带jdk1.7 一 安装jenkins wget -O :下载并以不同的文件 ...

  6. Redis-SDS

    Redis 的简单动态字符串 (simple dynamic string,SDS) SDS的结构: struct sdshdr { int len;  //保存的字符串长度. int free;  ...

  7. Bootstrap框架和inconfont、font-awesome使用

    iconfont的使用:https://www.cnblogs.com/clschao/articles/10387580.html Bootstrap介绍 Bootstrap是Twitter开源的基 ...

  8. 关于npm构建angular2项目问题

    我在win10系统下用npm构建好angular2项目之后,在命令行下运行 ng serve --open,报一下错误: Unknown browser query 'basedir=$(dirnam ...

  9. Javascript获取For循环所用时间

    第一种: let tOne = new Date().getTime(); let n = new Date(); let hour = n.getHours() < 10 ? "0& ...

  10. centos配置网络

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE="eth0"BOOTPROTO=&qu ...