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. 夺命雷公狗---Thinkphp----6之管理员的增删改查之-未验证

    首先我们创建多一个控制器UserController.class.php,主要用于管理员的增删改查操作: 代码如下所示: <?php namespace Admin\Controller; us ...

  2. switch结构2016/03/08

    Switch  03/08 一.结构 switch(){  case *: ;break;……default: ;brek;} 练习:输入一个日期,判断这一年第几天? Console.Write(&q ...

  3. [Ubuntu] Install teamviewer9 on Ubuntu14.04_x64

    The article copied from http://ubuntuhandbook.org/index.php/2013/12/install-teamviewer-ubuntu-1404/ ...

  4. JSP-02- 使用JSP实现输出

    二. 使用JSP实现输出 JSP的页面构成: 静态内容.指令.表达式.Scriptlet.声明.动作.注释 Jsp脚本: 表达式.Scriptlet.声明 表达式: <%=  内容  %> ...

  5. java web sql注入测试(1)---概念概述

    在进行java web 测试时,经常会忽略的测试种类就是sql注入测试,这类缺陷造成的原因是开发技术在这方面欠缺的表现,虽然不常见,但一旦有这类缺陷,就很因此对运营的数据造成很多不必要的损失,所以,还 ...

  6. yii2开启session

    1.在写入session的页面. use yii\web\Session;$session = new Session;$session->open(); 2.在获取session的页面 use ...

  7. mysql字段varchar区分大小写utf8_bin、utf8_general_ci编码区别

    mysql字段varchar区分大小写utf8_bin.utf8_general_ci编码区别 在mysql中存在着各种utf8编码格式:utf8_bin将字符串中的每一个字符用二进制数据存储,区分大 ...

  8. ubuntu屏幕分辨率问题

    今天在ubuntu下工作时突然屏幕上下各出现了一个大概2厘米的黑条,感觉屏幕被横向拉长了,莫名其妙,开始以为简单的调整下分辨率就好了,在系统设置显示里面发现分辨率只有两个可选参数,并且对象为未知,由于 ...

  9. java技术用ssh从linux服务器下载数据

    通常需要从linux服务器获取数据文件,而通常能有的访问方式只有ssh,所以就可以用ssh进行数据下载. java连接远程主机的方式有多种,这里和大家分享的是通过ssh方式连接远程主机,使用的是jsc ...

  10. Could not write metadata for '/taiping-sol-insu-composite'.

    Could not write metadata for '/taiping-sol-insu-composite'. 这是由于删除一个项目时,没有同时在硬盘上删除该项目,而后又到硬盘文件系统中删除了 ...