嘟嘟嘟

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

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




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

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cmath>
  4. #include<algorithm>
  5. #include<cstring>
  6. #include<cstdlib>
  7. #include<cctype>
  8. #include<vector>
  9. #include<stack>
  10. #include<queue>
  11. using namespace std;
  12. #define enter puts("")
  13. #define space putchar(' ')
  14. #define Mem(a, x) memset(a, x, sizeof(a))
  15. #define rg register
  16. typedef long long ll;
  17. typedef double db;
  18. const int INF = 0x3f3f3f3f;
  19. const db eps = 1e-8;
  20. const int maxn = 1e3 + 5;
  21. inline ll read()
  22. {
  23. ll ans = 0;
  24. char ch = getchar(), last = ' ';
  25. while(!isdigit(ch)) last = ch, ch = getchar();
  26. while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  27. if(last == '-') ans = -ans;
  28. return ans;
  29. }
  30. inline void write(ll x)
  31. {
  32. if(x < 0) x = -x, putchar('-');
  33. if(x >= 10) write(x / 10);
  34. putchar(x % 10 + '0');
  35. }
  36. int n;
  37. struct Vec
  38. {
  39. db x, y;
  40. db operator * (const Vec& oth)const
  41. {
  42. return x * oth.y - oth.x * y;
  43. }
  44. }a[maxn];
  45. db area()
  46. {
  47. a[n + 1] = a[1];
  48. db ans = 0;
  49. for(int i = 1; i <= n; ++i) ans += a[i] * a[i + 1];
  50. ans = ans < -eps ? -ans : ans;
  51. return ans / 2.00;
  52. }
  53. int main()
  54. {
  55. while(scanf("%d", &n) && n)
  56. {
  57. for(int i = 1; i <= n; ++i) scanf("%lf%lf", &a[i].x, &a[i].y);
  58. printf("%.0f\n", area());
  59. }
  60. return 0;
  61. }

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. CSS级联样式表-css选择器

    CSS概念 Cascading Style sheet 级联样式表 表现HTMl或XHTML文件样式的计算机语言 包括对字体,颜色,边距,高度,宽度,背景图片,网页定位等设定 建议:把表示样式的代码从 ...

  2. 出现<authentication mode="Windows"/>错误解决办法

    转自:https://blog.csdn.net/clever101/article/details/39671715 网上下载的asp.net源码出现 <authentication mode ...

  3. Docker学习(四): 操作容器

    特别声明: 博文主要是学习过程中的知识整理,以便之后的查阅回顾.部分内容来源于网络(如有摘录未标注请指出).内容如有差错,也欢迎指正! =============系列文章============= 1 ...

  4. Best MVC Practices 最佳的MVC实践

    Although Model-View-Controller (MVC) is known by nearly every Web developer, how to properly use MVC ...

  5. HBase—列族数据库的术语

    1. 列族数据库的基本组件 键空间,行键,列,列族 2. 什么是键空间 keyspace? 键空间 keyspace 是列族数据库的顶级数据结构,它在逻辑上能够容纳列族,行键以及与之相关的其他数据结构 ...

  6. Java 运行时数据区域

    1. 整体分类 程序计数器 虚拟机栈 本地方法栈 Java 堆 方法区 运行时常量池 直接内存 2. 程序计数器 每个线程一个计数器,线程的私有内存 指向的是字节码的内存地址? 如果线程执行的是 Ja ...

  7. UVA1583(最小生成元)

    对于这种需要一遍遍枚举求解的,打表可以提高很多效率 #include <iostream> #include <string> #include <cstring> ...

  8. IDEA 如何加上 tomcat

    前言: idea 上已经有一个 tomcat 了,因为这个 tomcat 为 32 的,需要加一个 64 为的 tomcat . 第一步: 第二步: 第三步: 点击 OK 就好. 结果:

  9. js 对象数组去重

    var arr = [{ "name": "ZYTX", "age": "Y13xG_4wQnOWK1QwJLgg11d0pS4h ...

  10. 通过Application存取公共数据比如登录信息等..

    Android系统在运行每一个程序应用的时候,都会创建一个Application对象,用于存储与整个应用相关的公共变量.一个Android应用只会生成一个Application对象,在不同的Activ ...