Moon Game (凸四边形个数,数学题)
Problem 2148 Moon Game
Accept: 24 Submit: 61 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
Sample Output
#include<stdio.h>
#include<math.h>
#include<string.h>
#define MAX 35
__int64 ans[MAX][]; int cheak(int i,int j,int k,int l)
{ __int64 x1,y1,x2,y2,x3,y3,x4,y4;
x1=ans[i][];
y1=ans[i][];
x2=ans[j][];
y2=ans[j][];
x3=ans[k][];
y3=ans[k][];
x4=ans[l][];
y4=ans[l][];
double k1,k2,b1,b2,s1,s2,s3,s4;
if(x2==x1&&x3==x4)
return ;
if(x2==x1&&x3!=x4)
{
s1=x3-x1;
s2=x4-x1;
if(s1*s2>=)
return ;
else
{
k2=(y3-y4)*1.0/(x3-x4);
b2=y3-k2*x3;
s3=(y2-b2)-k2*x2;
s4=(y1-b2)-k2*x1;
if(s3*s4>=)
return ;
if(s1*s2<&&s3*s4<)
return ;
} }
if(x3==x4&&x1!=x2)
{
s3=x1-x3;
s4=x2-x3;
if(s3*s4>=)
return ;
else
{
k1=(y2-y1)*1.0/(x2-x1);
b1=y1-k1*x1;
s1=(y3-b1)-k1*x3;
s2=(y4-b1)-k1*x4;
if(s1*s2>=)
return ;
if(s1*s2<&&s3*s4<)
return ;
}
}
else
{
k1=(y2-y1)*1.0/(x2-x1);
b1=y1-k1*x1;
s1=(y3-b1)-k1*x3;
s2=(y4-b1)-k1*x4;
if(s1*s2>=)
{
return ;
}
else
{
k2=(y3-y4)*1.0/(x3-x4);
b2=y3-k2*x3;
s3=(y2-b2)-k2*x2;
s4=(y1-b2)-k2*x1;
if(s3*s4>=)
return ;
if(s1*s2<&&s3*s4<)
return ;
}
}
} int main()
{
int T,N;
int i,j,k,l,cnt;
scanf("%d",&T);
for(cnt=;cnt<=T;cnt++)
{
scanf("%d",&N);
memset(ans,,sizeof(ans));
for(i=;i<N;i++)
{
scanf("%I64d%I64d",&ans[i][],&ans[i][]);
}
int temp=;
for(i=;i<N-;i++)
for(j=i+;j<N-;j++)
for(k=j+;k<N-;k++)
for(l=k+;l<N;l++)
{
if(cheak(i,j,k,l))
temp++;
if(cheak(i,k,j,l))
temp++;
if(cheak(i,l,k,j))
temp++;
}
printf("Case %d: %d\n",cnt,temp); }
return ;
} /*
20
4
0 0
100 0
0 100
100 100
5
0 0
10 0
0 5
5 5
15 0
4
0 0
100 0
0 100
10 10
5
1 1
5 6
9 7
5 5
2 2
4
1 1
1 1
1 1
1 1
5
1 1
2 2
3 3
4 4
5 5
6
5 8
6 4
1 0
10 5
8 6
3 5 */
表示比赛的时候策略错误。。。应该让我自己做这题的,不过还是很感谢我给力的队友啊。。。
(虽然我是个小坑! o(∩_∩)o 哈哈)那么我会好好努力的,大家一起加油哈!
Moon Game (凸四边形个数,数学题)的更多相关文章
- HDU3629(凸四边形的个数)
HDU 3629 计算几何 题目描述:给你n个点(4~700), 问你能够成多少个不同的凸四边形. 解题报告: 暴力的话C(700,4)必然超时,发现,任何一个凹包必然是其中一点在其它3点构成的三角形 ...
- FZU Problem 2148 Moon Game (判断凸四边形)
题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...
- 暴力(判凸四边形) FZOJ 2148 Moon Game
题目传送门 题意:给了n个点的坐标,问能有几个凸四边形 分析:数据规模小,直接暴力枚举,每次四个点判断是否会是凹四边形,条件是有一个点在另外三个点的内部,那么问题转换成判断一个点d是否在三角形abc内 ...
- 172. Factorial Trailing Zeroes(阶乘中0的个数 数学题)
Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explan ...
- ACM学习历程—FZU2148 Moon Game(计算几何)
Moon Game Description Fat brother and Maze are playing a kind of special (hentai) game in the clearl ...
- Problem A: 踢罐子 解题报告
Problem A: 踢罐子 Description 平面上有\(n\)个点,其中任意2点不重合,任意3点不共线. 我们等概率地选取一个点A,再在剩下的\(n-1\)个点中等概率地选取一个点B,再在剩 ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- ACM: FZU 2148 Moon Game - 海伦公式
FZU 2148 Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- 数论 - Moon Game
Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we ca ...
随机推荐
- [面试题目]IT面试中的一些基础问题
1. 面向对象的特征 继承,封装,多态 2. 重写和重载的区别 重写:在继承当中,子类重写父类的函数,函数声明完全一样,只是函数里面的操作不一样,这样叫做重写. 重载:与多态无关,即两个函数名一样的成 ...
- vue.js 的起步
vue.js 的起步 转载 作者:伯乐在线专栏作者 - 1000copy 点击 → 了解如何加入专栏作者 如需转载,发送「转载」二字查看说明 介绍 vue.js 是一个客户端js库,可以用来开发单页应 ...
- 阿里云RDS数据库备份文件恢复到本地数据库
参考这里:https://help.aliyun.com/knowledge_detail/41817.html 第4.2步要多注释掉一些(应该根据实际报错来注释): [mysqld] innodb_ ...
- web socket 入门
WebSocket是HTML5开始提供的一种在单个 TCP 连接上进行全双工通讯的协议,其优雅地解决了以往web服务器不能向web客户端实时推送消息的问题. 在浏览器js环境中,创建一个websock ...
- mysql之视图,存储过程,触发器,事务
视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的临时 ...
- Linux学习系列之一:在centos 7.5上安装nginx 以及简单配置
说到Linux我们都知道那是相当相当得重要得啊,在计算机这个行业,开发运维都是离不开它得.我作为一个准毕业生,智商可能不太够,只能自己笨鸟先飞,自己操作起来咯.俗话说的好,好记性不如难笔头嘛.而且ng ...
- Java时间类(转)
package com.chinagas.common.utils; import java.text.ParseException; import java.text.SimpleDateForma ...
- 五、CLR加载程序集代码时,JIT编译器对性能的产生的影响
1.CLR首次加载代码造成的性能损失 四.CLR执行程序集中代码介绍了CLR在首次执行一个类的时,会初始化一个内部结构,然后当目标方法被首次调用时,JITComplier函数(JIT编译器)会验证IL ...
- 全网最详细的大数据集群环境下如何正确安装并配置多个不同版本的Cloudera Hue(图文详解)
不多说,直接上干货! 为什么要写这么一篇博文呢? 是因为啊,对于Hue不同版本之间,其实,差异还是相对来说有点大的,具体,大家在使用的时候亲身体会就知道了,比如一些提示和界面. 全网最详细的大数据集群 ...
- 【原创】用JQury来制作星星打分特效功能
前言 常常我们看到一些评论,星星打分,今天我们就用Jq代码来实现,看看究竟是如何实现的 其中有两个重要的事件mouseenter和mouseleave效果如下图 代码 <!DOCTYPE htm ...