Moon Game

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

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

2 4 0 0 100 0 0 100 100 100 4 0 0 100 0 0 100 10 10

Sample Output

Case 1: 1 Case 2: 0
 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std; int T;
int n,ca=;
int i,j,k,l;
double x[],y[]; double S(double x1,double y1,double x2,double y2,double x3,double y3)
{
double K=(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2)/2.0;
return fabs(K);
} int check()
{
double S123,S124,S134,S234;
S123=S(x[i],y[i],x[j],y[j],x[k],y[k]);
S124=S(x[i],y[i],x[j],y[j],x[l],y[l]);
S134=S(x[i],y[i],x[k],y[k],x[l],y[l]);
S234=S(x[j],y[j],x[k],y[k],x[l],y[l]);
//printf("%lf %lf %lf %lf\n",S123,S124,S134,S234);
if(fabs(S124+S134+S234-S123)==)
return ;
if(fabs(S124+S134-S234+S123)==)
return ;
if(fabs(S124-S134+S234+S123)==)
return ;
if(fabs(S134+S234+S123-S124)==)
return ;
return ;
} int main()
{
scanf("%d",&T);
while(T--)
{
int num=;
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%lf %lf",&x[i],&y[i]);
for(i=;i<=n-;i++)
{
for(j=i+;j<=n-;j++)
{
for(k=j+;k<=n-;k++)
{
for(l=k+;l<=n;l++)
{
//printf("%d %d %d %d\n",i,j,k,l);
if(check()==)
num++;
}
}
}
} printf("Case %d: %d\n",ca++,num);
}
return ;
}

FZU 2148 Moon Game的更多相关文章

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

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

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

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

  3. FZU 2148 Moon Game --判凹包

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

  4. FZOJ Problem 2148 Moon Game

                                                                                                  Proble ...

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

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

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

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

  7. 暴力(判凸四边形) FZOJ 2148 Moon Game

    题目传送门 题意:给了n个点的坐标,问能有几个凸四边形 分析:数据规模小,直接暴力枚举,每次四个点判断是否会是凹四边形,条件是有一个点在另外三个点的内部,那么问题转换成判断一个点d是否在三角形abc内 ...

  8. Moon Game (凸四边形个数,数学题)

    Problem 2148 Moon Game Accept: 24    Submit: 61 Time Limit: 1000 mSec    Memory Limit : 32768 KB Pro ...

  9. FZU-2148-Moon Game,,几何计算~~

    Problem 2148 Moon Game Time Limit: 1000 mSec Memory Limit : 32768 KB  Problem Description Fat brothe ...

随机推荐

  1. 2. 星际争霸之php面向对象(二)

    题记==============================================================================本php设计模式专辑来源于博客(jymo ...

  2. JSP-09-使用EL显示数据

    目的:为了使JSP写起来更加简单. 9.1  EL表达式 ${EL表达式}  :  ${unsername} 操作符:   “. ”操作符: 用来访问对象的属性    ${news.title} “[ ...

  3. SSAS中角色(Role)定义需要注意的两个地方

    开发过SSAS Cube的朋友应该都知道,我们可以在SSAS中设置若干个角色,把windows账号放入这些角色中来限制不同的windows账号可以看到的数据有哪些,这里有两点需要注意一下. 首先在Cu ...

  4. Openstack的ping不通实例的解决办法

    状态:实例在管理平台上正常创建,也能vnc到实例里面使用ifconfig,查看IP得到我们想要的IP,但是在除了计算节点以外的机器ping实例就是不通. 操作:主要为了测试网络51删除,重新创建网络5 ...

  5. Android多线程通信之Handler

    主线程 public class MainActivity extends ActionBarActivity { private Handler handler; // private Thread ...

  6. ueditor .NET版本提示uploader、Config类同时存在于两个dll中

    在网上查看了下,主要有两种解决办法 1.直接删除,以下引用. <%@ Assembly Src="Uploader.cs" %><%@ Assembly Src= ...

  7. 160829、Java加解密与数字签名

    ** Java加解密 ** 实现方式:JDK实现,CC,BC JDK提供比较基础的底层的实现:CC提供一些简化的操作:BC提供补充 一.Base64加密 非常简单,加密解密就一个函数. 代码如下: 二 ...

  8. 电影TS、TC、SCR、R5、BD、HD等版本是什么意思

    在很多电影下载网站的影片标题中我们都能看到,比如<刺杀希特勒BD版>.<游龙戏凤TS版>等,这些英文缩写都是什么意思呢?都代表什么画质?以下就是各个版本的具体含义: 1.CAM ...

  9. Python 的命令行参数处理 optparse->argparse

    optaprse自2.7版开始弃用:弃用optparse模块,不会进一步开发,将继续开发argparse模块作为替代. 但是用习惯了optparse,还是很好用的撒. optparse使用起来,相比旧 ...

  10. 14 个 grep 命令的例子 【转】

    转自:https://linux.cn/article-5453-1.html 编译自:http://www.linuxtechi.com/linux-grep-command-with-14-dif ...