FZU 2148 Moon Game 判断凸边形
来源:互联网 发布:程序员面试算法题 编辑:程序博客网 时间:2024/06/16 16:23
Accept: 512 Submit: 1419
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dimensional plane. Then Fat brother starts to draw N starts in the sky which we can just consider each as a point. After he draws these stars, he starts to sing the famous song “The Moon Represents My Heart” to Maze.
You ask me how deeply I love you,
How much I love you?
My heart is true,
My love is true,
The moon represents my heart.
…
But as Fat brother is a little bit stay-adorable(呆萌), he just consider that the moon is a special kind of convex quadrilateral and starts to count the number of different convex quadrilateral in the sky. As this number is quiet large, he asks for your help.
Input
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains an integer N describe the number of the points.
Then N lines follow, Each line contains two integers describe the coordinate of the point, you can assume that no two points lie in a same coordinate and no three points lie in a same line. The coordinate of the point is in the range[-10086,10086].
1 <= T <=100, 1 <= N <= 30
Output
For each case, output the case number first, and then output the number of different convex quadrilateral in the sky. Two convex quadrilaterals are considered different if they lie in the different position in the sky.
Sample Input
Sample Output
//140 ms216KB#include<stdio.h>#include<math.h>#define eps 1e-9struct P{ int x,y;}p[1007];double area(P a, P b, P c){ return a.x * b.y + c.x * a.y + b.x * c.y - c.x * b.y - a.x * c.y - b.x * a.y;}bool ok(P a,P b,P c,P d){ double sum1 = fabs(area(a, b, d)) + fabs(area(a, c, d)) + fabs(area(b, c, d)); double sum2 = fabs(area(a, b, c)); if(sum1==sum2)return true; return false;}bool judge(P a,P b,P c,P d){ if(ok(a,b,c,d))return false; if(ok(a,b,d,c))return false; if(ok(a,c,d,b))return false; if(ok(b,c,d,a))return false; return true;}int main(){ int t,cas=1; scanf("%d",&t); while(t--) { int n,ans=0; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d%d",&p[i].x,&p[i].y); for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) for(int x=j+1;x<n;x++) for(int y=x+1;y<n;y++) if(judge(p[i],p[j],p[x],p[y])) ans++; printf("Case %d: %d\n",cas++,ans); } return 0;}
- FZU 2148 Moon Game 判断凸边形
- FZU 2148 Moon Game(判断凸边形(凹边形))
- fzu 2148 Moon Game
- FZU 2148 Moon Game
- FZU - 2148 Moon Game
- FZU-2148 Moon Game
- FZU 2148 Moon Game
- FZU-2148-Moon Game
- FZU 2148 Moon Game
- FZU-2148-Moon Game
- Fzu 2148 Moon Game 判断凸四边形 判断线段相交
- FZU 2148 Moon Game(判断凸四边形的个数)
- 【判断点在不在三角形内】FZU 2148 Moon Game
- FZU 2148 ——Moon Game 判断凸四边形
- fzu 2148 Moon Game(暴力+几何)
- FZU 2148: Moon Game 四边形的月亮
- FZU 2148 Moon Game(几何题)
- 【暴力+排除法】FZU 2148 Moon Game
- cocos2dx实现手指控制物体移动
- 2015超实用的前端开发指南
- 操作系统虚拟化原理总结篇——VMCS详解
- Java基础第一讲
- Android学习笔记——eclipse打开后出现Failed to load the JNI shared library .. \jvm.dll 问题
- FZU 2148 Moon Game 判断凸边形
- PPT
- Sql server中mybatis分页提示 'ROWNUMBER' 不是可以识别的内置函数名称
- Irrlicht1.7.1在VS2012上的环境搭建
- 看操作系统虚拟化原理总结篇——VMCS详解
- 黑马程序员_Obeject类的总结
- jjklkg
- UVA 10878 解题报告
- hdu 3571 N-dimensional Sphere(高斯消元+移位乘法)