FZU 2148 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
Sample Output
#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的更多相关文章
- ACM: FZU 2148 Moon Game - 海伦公式
FZU 2148 Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- FZU 2148 moon game (计算几何判断凸包)
Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit St ...
- FZU 2148 Moon Game --判凹包
题意:给一些点,问这些点能够构成多少个凸四边形 做法: 1.直接判凸包 2.逆向思维,判凹包,不是凹包就是凸包了 怎样的四边形才是凹四边形呢?凹四边形总有一点在三个顶点的内部,假如顶点为A,B,C,D ...
- FZOJ Problem 2148 Moon Game
Proble ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- FZU Problem 2148 Moon Game (判断凸四边形)
题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...
- 暴力(判凸四边形) FZOJ 2148 Moon Game
题目传送门 题意:给了n个点的坐标,问能有几个凸四边形 分析:数据规模小,直接暴力枚举,每次四个点判断是否会是凹四边形,条件是有一个点在另外三个点的内部,那么问题转换成判断一个点d是否在三角形abc内 ...
- Moon Game (凸四边形个数,数学题)
Problem 2148 Moon Game Accept: 24 Submit: 61 Time Limit: 1000 mSec Memory Limit : 32768 KB Pro ...
- FZU-2148-Moon Game,,几何计算~~
Problem 2148 Moon Game Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Fat brothe ...
随机推荐
- 夺命雷公狗---微信开发17----自定义菜单的事件推送,响应菜单的CLICK
废话不多说,index.php 代码如下所示: <?php /** * wechat php test */ //define your token require_once "com ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON DirectFile
zw版[转发·台湾nvp系列Delphi例程]HALCON DirectFile unit Unit1;interfaceuses Windows, Messages, SysUtils, Varia ...
- 给Debian浏览器安装flash播放插件
sudo apt-get install flashplugin-nonfree
- SQLServer出现 '其他会话正在使用事务的上下文' 的问题原因,什么是环回链接服务器?(转载)
本人经过百度查找并且自己进行测试得到问题原因: MSDN上看了一下说是sql server 不支持在分布式事务处理中存在指向本地的链接服务器(环回链接服务器) 通过上面简单说明大家有可能没完全理解环回 ...
- SSAS 聚合设计提升CUBE的查询性能(转载)
Problem What exactly are SQL Server Analysis Services (SSAS) Aggregations and how exactly can I revi ...
- c++实现mlp神经网络
之前一直用theano训练样本,最近需要转成c或c++实现.在网上参考了一下其它代码,还是喜欢c++.但是看了几份cpp代码之后,发现都多少有些bug,很不爽.由于本人编码能力较弱,还花了不少时间改正 ...
- innodb的锁时间
观察innodb的锁时间,需要关注: mysqladmin extended-status -r -i 1 -uroot | grep "Innodb_row_lock_time" ...
- scala泛型
package com.ming.test /** * scala泛型 * 类型参数测试 */ object TypeParamsTest { //泛型函数 def getMiddle[T](a:Ar ...
- 将txt文件数据转成bin文件.
之前用牛逼的绘图以及分析bmp的像素文件的方法, 整理出汉字编码从: 0x4E00到0x9FA5, (维基上说是9FD5, 完了, 回头再更新吧.) https://en.wikipedia.org/ ...
- SQL Server系统表sysobjects介绍与使用
关于SQL Server数据库的一切信息都保存在它的系统表格里.我怀疑你是否花过比较多的时间来检查系统表格,因为你总是忙于用户表格.但是,你可能需要偶尔做一点不同寻常的事,例如数据库所有的触发器.你可 ...