Area
2013-07-29 10:52
29 查看
http://poj.org/problem?id=1265
View Code
#include<cstdio> #include<istream> #include<algorithm> #include<cmath> int n; using namespace std; const int maxn=100; const double pi=acos(-1.0); int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } struct Point //点的定义 { double x,y; Point() {} Point (double a,double b):x(a),y(b) {} }; Point a[maxn],b[maxn]; double del(const Point &a,const Point &b) { return(a.x*b.y-a.y*b.x); } int main() { int t,c=0; scanf("%d",&t); while(t--) { c++; scanf("%d",&n); int xx=0,yy=0,x,y,num=0; for(int i=0; i<n; i++){ scanf("%d%d",&x,&y); num+=gcd(abs(x),abs(y)); b[i+1].x=xx+x; b[i+1].y=yy+y; xx=b[i+1].x; yy=b[i+1].y; } double sum=0; b[0].x=0; b[0].y=0; for(int i=0; i<n; i++) sum+=del(b[i],b[i+1]); printf("Scenario #%d:\n",c); printf("%d %d %.1lf\n",int(sum/2.0)+1-(num/2),num,sum/2); printf("\n"); } }
View Code
相关文章推荐
- How to Monte Carlo Sampling Area Light and What physics quantity is the real percption?
- html基础 — area(图像的作用区域标记)
- html基础 — area(图像的作用区域标记)
- CSDN SQL Area --行列互转
- Mobile WiMAX: Toward Broadband Wireless Metropolitan Area Networks (Wireless Networks and Mobile Com
- JQUERY获取text,areatext,radio,checkbox,select值(转)
- 震撼!Area-51 X58
- Area
- FusionChart Stacked Area Chart使用方法
- Oracle10g如何释放flash_recovery_area,解决ORA-19815错误
- JQUERY 获取text,areatext,radio,checkbox,select值
- jquery extension - auto height text area
- JQUERY获取text,areatext,radio,checkbox,select值
- 定义一个抽象类Shape,成员有图形名称(name)和求面积的抽象方法Area()
- linux内核学习笔记-struct vm_area_struct
- 如何使用QScrollArea
- Oracle10g如何释放flash_recovery_area,解决ORA-19815错误
- Single Area OSPF
- HDU 1798 Tell me the area
- poj 1265 pick定理的应用—Area