Accept: 710    Submit: 2038

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

240 0100 00 100100 10040 0100 00 10010 10

 Sample Output

Case 1: 1Case 2: 0

我直接用了凸包算法,大材小用了

#include <iostream>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm> using namespace std;
struct Node
{
int x;
int y;
}a[5],b[35];
int s[10];
int top;
int cross(Node a,Node b,Node c)
{
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
int dis(Node a,Node b)
{
return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int cmp(Node p1,Node p2)
{
int temp=cross(a[0],p1,p2);
if(temp>0) return true;
else if(temp==0&&dis(a[0],p1)<dis(a[0],p2)) return true;
else return false;
}
int cmp2(Node a,Node b)
{
if(a.y==b.y)
return a.x<b.x;
return a.y<b.y;
}
int graham(int n)
{
if(n==1){return 0;}
if(n==2){return 1;}
if(n>2)
{
top=1;s[0]=0;s[1]=1;
for(int i=2;i<n;i++)
{
while(top>0&&cross(a[s[top-1]],a[s[top]],a[i])<=0)
top--;
s[++top]=i;
} return top; } }
int n;
int main()
{
int t;
scanf("%d",&t);
int cas=0;
int ans=0;
while(t--)
{
scanf("%d",&n);
ans=0;
for(int i=1;i<=n;i++)
scanf("%d%d",&b[i].x,&b[i].y);
for(int i=1;i<=n;i++)
{ for(int j=i+1;j<=n;j++)
{ for(int k=j+1;k<=n;k++)
{ for(int p=k+1;p<=n;p++)
{
a[0]=b[i];a[1]=b[j];a[2]=b[k];a[3]=b[p];
sort(a,a+4,cmp2); sort(a+1,a+4,cmp); //cout<<i<<" "<<j<<" "<<k<<" "<<p<<endl;
if(graham(4)==3)
{
// cout<<i<<" "<<j<<" "<<k<<" "<<p<<endl;
ans++;
}
}
}
}
}
printf("Case %d: %d\n",++cas,ans);
}
return 0;
}

FZU Moon Game(几何)的更多相关文章

  1. fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)

    题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...

  2. ACM: FZU 2148 Moon Game - 海伦公式

     FZU 2148  Moon Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  3. FZU 2148 Moon Game

    Moon Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  4. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

  5. FZU 2148 moon game (计算几何判断凸包)

    Moon Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  6. fzu 2035 Axial symmetry(枚举+几何)

    题目链接:fzu 2035 Axial symmetry 题目大意:给出n个点,表示n边形的n个顶点,判断该n边形是否为轴对称图形.(给出点按照图形的顺时针或逆时针给出. 解题思路:将相邻两个点的中点 ...

  7. FZU 2148 Moon Game --判凹包

    题意:给一些点,问这些点能够构成多少个凸四边形 做法: 1.直接判凸包 2.逆向思维,判凹包,不是凹包就是凸包了 怎样的四边形才是凹四边形呢?凹四边形总有一点在三个顶点的内部,假如顶点为A,B,C,D ...

  8. FZU 2140 Forever 0.5 (几何构造)

    Forever 0.5 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  9. FZU Problem 2148 Moon Game (判断凸四边形)

    题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...

随机推荐

  1. 通过CLR API实现C++调用C#代码交互

    对于某些跨平台程序,这也就意味着只能在windows下使用了 不过最近.Net开源或许以后可以跨平台 之前花了一些时间研究COM方式调用,太繁琐不推荐. COM方式调用总结 后来尝试使用CLR C++ ...

  2. atitit.为什么 java开发要比php开发速度慢??

    atitit.为什么 java开发要比php开发速度慢?? 1. 界面开发方面vs php 1 2. 架构繁琐 1 3. 环境配置复杂 1 4. 类库jar包冲突(严重) 1 5. 配置文件热部署的缺 ...

  3. 改动app的默认设置(包含改动默认launcher)

    1.改为自己的launcher ComponentName component = new ComponentName( context.getPackageName(), MainActivity. ...

  4. 判断是否是IE浏览器和是否是IE11

    判断是否是IE浏览器用下面这个函数, function isIE() { //ie? 是ie返回true,否则返回false if (!!window.ActiveXObject || "A ...

  5. android.animation(7) - android:animateLayoutChanges属性和LayoutTransition

    前篇给大家讲了LayoutAnimation的知识,LayoutAnimation虽能实现ViewGroup的进入动画,但只能在创建时有效.在创建后,再往里添加控件就不会再有动画.在API 11后,又 ...

  6. xadmin 安装详解

    1.安装必要的包 django>=1.9.0 django-crispy-forms>=1.6.0 django-import-export>=0.5.1 django-revers ...

  7. URL与URI

    1.URI是统一资源标识符,是一个用于标识某一互联网资源名称的字符串. 该种标识允许用户对任何(包括本地和互联网)的资源通过特定的协议进行交互操作.URI由包括确定语法和相关协议的方案所定义.由是三个 ...

  8. floyd算法&迪杰斯特拉算法

    ; k<=n; k++) ; i<=n; i++) ; j<=n; j++) { gra[i][j]=min(gra[i][j],gra[i][k]+gra[k][j]); } vo ...

  9. wcf客户端终结点样本集合

    1. <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IUser" /&g ...

  10. 转:Linux下which、whereis、locate、find 命令的区别

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.这些是从网上找到的资料,因为有时很长时间不会用到,当要用的时候经常弄混了,所以放到这里方便使用. which    ...