FZU 2148 Moon Game(判断凸边形(凹边形))

原创 2016年06月01日 17:35:28

Moon Game


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.


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


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

240 0100 00 100100 10040 0100 00 10010 10

Sample Output

Case 1: 1Case 2: 0






#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

const double eps = 1e-9;
struct Point{
    double x,y;
    Point(double x=0,double y=0):x(x),y(y){} // 构造函数,方便代码编写
typedef Point Vector;  //从程序实现上,Vector只是Point的别名

Vector operator - (Vector A,Vector B){
    return Vector(A.x-B.x,A.y-B.y);

double Cross(Vector A,Vector B){
    return A.x*B.y - A.y*B.x;

double area(Point a, Point b, Point c){
     return Cross(b-a,c-a)/2;

bool check(Point a,Point b,Point c,Point 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(fabs(sum1 - sum2) < eps) return true;
    return false;

bool solve(Point a,Point b,Point c,Point d){
    if(check(a,b,c,d)) return false;
    if(check(a,b,d,c)) return false;
    if(check(a,c,d,b)) return false;
    if(check(b,c,d,a)) return false;
    return true;

int main(){
    int T,t = 1;
        int n,ans = 0;
        for(int i = 0; i < n; ++i)
        for(int i = 0; i < n; ++i)
            for(int j = i+1; j < n; ++j)
                for(int k = j+1; k < n; ++k)
                    for(int l = k+1; l < n; ++l)
        printf("Case %d: %d\n",t++,ans);
    return 0;



这位大牛的总结的很好,我是学习这位大牛的博客 http://blog.csdn.net/zhouxuguang236/article/details/10162553...
  • wo_shazi
  • wo_shazi
  • 2014年11月22日 21:59
  • 329

FZU 2148 Moon Game 判断凸边形

点击打开链接 Problem 2148 Moon Game Accept: 512    Submit: 1419 Time Limit: 1000 mSec    Memory Limit...
  • Dinivity123
  • Dinivity123
  • 2015年04月17日 22:50
  • 746


  • to_myslef
  • to_myslef
  • 2017年04月17日 16:11
  • 342


1.题目: Problem Description 以n(n>3)边形的n个顶点和它内部的m(m为正整数)个点,共(m+n)个顶点作为顶点,可把原n边形分割成多少个互不重叠的小三角形? ...
  • u010102829
  • u010102829
  • 2013年07月27日 11:04
  • 1251

Problem 2148 Moon Game --福州大学

地址:http://acm.fzu.edu.cn/problem.php?pid=2148 解题思路   这题目很简单:给多个不重复坐标点,求不重复的凸四边形个数。而且n最大是30,所以枚举所有四...
  • u012964281
  • u012964281
  • 2013年12月27日 13:06
  • 1070

使用Unity Mesh生成正N边形

原文链接 : http://www.manew.com/thread-98971-1-1.html 效果:  边数多了就会变成这样: 代码如下 : using UnityEngine...
  • qq_28221881
  • qq_28221881
  • 2017年01月19日 22:09
  • 649


已知四边形四个点坐标 p1 = (x,y), p2 = (x,y), p3 = (x,y), p4 = (x,y) 判断凹凸性及凹点位置    t1 = (p4.x-p1.x)(p2.y-p1....
  • Coding_Dreaming
  • Coding_Dreaming
  • 2016年02月21日 21:41
  • 1338


Shape of HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T...
  • z8110
  • z8110
  • 2015年07月29日 21:23
  • 394

fzu 2148 Moon Game

I - Moon Game 题目链接 题目大意:给定n个点的坐标,判断能组成由多少凸四边形。 思路一:枚举三个点a,b,c,这三个点组成三角形ABC(若是直线也被认为是三角形),总剩下的点中取一...
  • twobqn123
  • twobqn123
  • 2014年01月24日 00:52
  • 459

FZU 2148 Moon Game

Description Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue ...
  • fuckohmylove
  • fuckohmylove
  • 2015年12月01日 18:39
  • 135
您举报文章:FZU 2148 Moon Game(判断凸边形(凹边形))