FZU_ Problem 2148 Moon Game
来源:互联网 发布:下载动画的软件 编辑:程序博客网 时间:2024/05/21 19:29
Accept: 386 Submit: 1080
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
4
0 0
100 0
0 100
100 100
4
0 0
100 0
0 100
10 10
Sample Output
Case 2: 0
http://acm.fzu.edu.cn/problem.php?pid=2148
//题意是求给定点最多能构成多少个凸四边形。
如何判断凸四边形: 如果4个点中存在某个点D,Sabd + Sacd + Sbcd = Sabc,则说明是凹四边形。因为n很小,所以直接暴力枚举每四个点是否构成凸四边形。
#include<cstdio>#include<cmath>using namespace std;const double eps=1e-8;struct point{ int x,y;}p[35];double area(point a,point b,point c) //三角形面积公式{ return fabs(1.0*(a.x*b.y+b.x*c.y+c.x*a.y-a.x*c.y-b.x*a.y-c.x*b.y))/2;}bool check(point a,point b,point c,point d) //判断是否是凸边形,注意 这里假设a为四边形的内点,要跟下面四重循环对应{ if(fabs(area(b,c,d)-area(a,b,c)-area(a,b,d)-area(a,c,d))<eps) //面积相等 return 0; return 1;}int main(){ int t,i,j,k,n,a,b,ans; scanf("%d",&t); for(k=1;k<=t;k++) { ans=0; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d",&p[i].x,&p[i].y); if(n<4) printf("Case %d: %d\n",k,ans); else { for(i=0;i<n;i++) for(j=i+1;j<n;j++) for(a=j+1;a<n;a++) for(b=a+1;b<n;b++) if(check(p[i],p[j],p[a],p[b])&&check(p[j],p[i],p[a],p[b])&&check(p[a],p[i],p[j],p[b])&&check(p[b],p[i],p[j],p[a])) ans++; printf("Case %d: %d\n",k,ans); } } return 0;}
- FZU_ Problem 2148 Moon Game
- Problem 2148 Moon Game --福州大学
- fzu 2148 Moon Game
- FZU 2148 Moon Game
- 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
- Moon Game
- Moon Game
- fzu 2148 Moon Game(暴力+几何)
- FZU 2148: Moon Game 四边形的月亮
- FZU 2148 Moon Game(几何题)
- 【暴力+排除法】FZU 2148 Moon Game
- FZU 2148 Moon Game(暴力+几何)
- IOS7状态栏标准适配
- 基数排序
- 取石子(一)--巴什博弈
- hdu 2768 Cat vs. Dog (最大独立集)
- hdu 1267 下沙的沙子有几粒?(递推&DP)
- FZU_ Problem 2148 Moon Game
- python字典
- 编程常用知识点大全(链接)
- COM(三)进程透明性、标准列集、自定义列集
- 打印二叉树的深度
- C语言 BMP图片处理
- 如何把pdf转换成excel转换器免费使用
- Codeforces Round #259 (Div. 2)-C. Little Pony and Expected Maximum
- CoreData学习记录