一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最后看了下别人的才过,我的代码就不发了,免得误导,不得不说几何真是...

还有就是这个大神的代码,貌似G++,过不了,C++AC

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
int moveY[] = {-, , , -, , , -, , };
int moveX[] = {-, -, -, , , , , , };
char step[];
#define EPS 1e-8
int main()
{
int t;
scanf("%d\n", &t);
int x, y, px, py;
double area;
long pos = ;
while (t--)
{
x = y = px = py = ;
pos = area = ;
scanf("%s", step);
while (step[pos] != '')
{
x = px + moveX[step[pos]-''];
y = py + moveY[step[pos]-''];
area += 0.5*(px*y-py*x);
px = x;
py = y;
pos++;
}
area = fabs(area);
if (fabs((long long)area - area)<EPS)
{
printf("%.0lf\n", area);
}
else
{
printf("%.1lf\n", area);
}
}
return ;
}

最新文章

  1. Visual Basic 2012 借助DataGridView控件将SQL server2012 数据导入到Excel 2010
  2. 使用keytool生产jks证书
  3. Linux学习笔记(8)Linux常用命令之网络命令
  4. Lucene4.3开发之分词器总结
  5. Java 集合深入理解(3):Collection
  6. 关于UNION ALL与 UNION 用法和区别
  7. Hibernate逍遥游记-第12章 映射值类型集合-002映射Bag(&lt;idbag&gt;&lt;collection-id&gt;)
  8. L-value 和 R-value.
  9. GC算法之串行并行并发
  10. JProfiler简明使用教程
  11. C语言一个双向链表的实现
  12. java之web开发过滤器
  13. 查看电脑系统参数(Windows)
  14. 分享:使用 TypeScript 编写的游戏代码
  15. CSS的继承和使用方式
  16. saltstack API(一) 安装并测试
  17. poj 1151 (未完成) 扫描线 线段树 离散化
  18. gentoo 图像方面的软件
  19. 数据库-mysql命令
  20. Git-简单的利用SourceTree提交代码

热门文章

  1. Lynis 2.2.0 :面向Linux系统的安全审查和扫描工具
  2. CSV文件解析工具
  3. SVN ---文件加锁,执行clean up命令
  4. 《JavaScript高级程序设计》读书笔记 ---操作符二
  5. 分珠(dfs+并查集)
  6. php curl调用相关api
  7. VBS脚本代码(手工编写---在windows 7上调用系统对话框,来选择文件)
  8. 只能在执行 Render() 的过程中调用 RegisterForEventValidation
  9. [Lua]Lua高级教程Metatables
  10. cpu、内存、缓存、硬盘使用率