POJ1654
来源:互联网 发布:js判断邮箱格式 编辑:程序博客网 时间:2024/06/07 03:00
看这蛮简单的一道题但是很坑,ans double类型的话会RE, 用LongLong
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
double x[10] = {0, -1, 0, 1, -1 , 0, 1, -1, 0 ,1};
double y[10] = {0, -1, -1, -1, 0, 0, 0, 1, 1, 1};
int main()
{
char str[1000010];
int t;
double x1,x2,y1,y2;
long long ans;
scanf("%d",&t);
while(t--)
{
y1 = y2 = x1 = x2 = ans = 0;
scanf("%s",str);
int len =strlen(str);
for( int i =0; i<len; i++)
{
x2 = x1 + x[str[i] - '0'];
y2 = y1 + y[str[i] - '0'];
ans += x1*y2 - x2 *y1;
x1 = x2;
y1 = y2;
}
if(ans <= 0)
ans = -ans;
if( ans %2 == 0 )
cout<<ans/2<<endl;
else
cout<<ans/2<<".5"<<endl;
}
return 0;
}
- poj1654
- POJ1654
- poj1654
- POJ1654
- poj1654
- poj1654
- poj1654 - Area
- POJ1654-Area
- poj1654 Area
- poj1654——Area
- poj1654---计算几何
- POJ1654叉积求多边形面积
- Area(poj1654多边形面积)
- poj1654叉积求多边形面积
- poj1654叉积求多边形面积
- poj1654 Area 计算几何
- poj1654(求多边形面积)
- poj1654--Area(几何求面积)
- 当前用户没有安装Microsoft office outlook
- Linux SPI总线和设备驱动架构之四:SPI数据传输的队列化
- POJ3635--Full Tank?(优先队列+最短路)
- tyvj1122 noip2009 最优贸易——by rfy
- ssh协议和telnet协议 理解 小结
- POJ1654
- [ACM] poj 1064 Cable master (二分查找)
- poj 2612 Mine Sweeper
- Wisemetrics :1%的Facebook Page仍有80%的粉丝触达率
- 关于面试
- 一道SQL的面试题之联想
- java参数传递(超经典)
- 如何读大学
- Timus 1644. A Whole Lot of Walnuts 算法