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 ...
随机推荐
- SQL—— 事务
SQL 事务: 1. 定义: 事务是作为单个逻辑单元执行的一系列操作. 多个操作作为一个整体向系统提交,要么执行.要么都不执行,事务是一个不可分割的工作逻辑单元.这特别适用于多用户同时操作的数据通信 ...
- Writable、WritableComparable和comparators
hadoop的序列化格式 hadoop自身的序列化存储格式就是实现了Writable接口的类,他只实现了前面两点,压缩和快速.但是不容易扩展,也不跨语言. 我们先来看下Writable接口,Writa ...
- ubuntu 修改终端命令显示的颜色
转于 http://www.blogbus.com/riusksk-logs/62891140.html 修改当前用户 gedit ~/.bashrc 在最后一行下面添加这行 PS1='${debi ...
- 20145227《Java程序设计》课程总结
20145227<Java程序设计>课程总结 每周读书笔记链接汇总 20145227 <Java程序设计>第1周学习总结 20145227 <Java程序设计>第2 ...
- 在chrome浏览器和在IE浏览器中显示的页面样式不一样的解决办法
在IE浏览器中添加 一行代码即可:<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 位 ...
- Chrome开发者工具学习
Chrome开发者工具分为8个大模块,每个模块功能为: 1.Element标签页:用于查看和编辑当前页面中的HTML和CSS元素. 左侧可以看到页面的源码,HTML和CSS元素,双击可以进行修改.右侧 ...
- ACM题目————列变位法解密
这是在百度之星看到的. Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐 ...
- C++TSL之map容器(悲伤的故事)
说一个悲伤地故事! 这几天正在加紧时间学STL!昨天刚刚勉强把map弄懂一点点.(故事的前提) 今天,来到平台准备刷有关map的题,老师推荐了一道题目.说是有关map.然后..不会!! 后来,百度.. ...
- 温故而知新 clone
浅复制(浅克隆) 被复制对象所有变量都含有与原来对象的相同值,对象中对其他对象的引用仍然指向原来的对象,换言之,复制对象只复制考虑的对象,而不复制所引用的对象.继承自java.lang.Object类 ...
- ScheduledExecutorService定时周期执行指定的任务
示例代码 package com.effective.common.concurrent.execute; import java.text.DateFormat; import java.text. ...