FZOJ Problem 2148 Moon Game
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
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int N_MAX = + ;
int n;
pair<ll, ll>cor[N_MAX]; ll fab(ll a) {
return a >= ? a : -a;
} int S(int a,int b,int c) {
return fab(cor[a].first*(cor[b].second-cor[c].second)+cor[b].first*(cor[c].second-cor[a].second)+cor[c].first*(cor[a].second-cor[b].second)) ;
} bool judge(int a,int b,int c,int d) {
if (S(a, b, c) == S(a, b, d) + S(a, c, d) + S(b, c, d))
return false;//凹四边形
return true;
} int main() {
int T;
scanf("%d", &T);
int cs = ;
while (T--) {
cs++;
scanf("%d",&n);
for (int i = ; i < n;i++) {
scanf("%lld%lld",&cor[i].first,&cor[i].second);
}
int num = ;
for (int i = ; i < n;i++)
for (int j = i + ; j < n;j++)
for (int k = j + ; k < n;k++)
for (int l = k + ; l < n; l++)
if (judge(i, j, k, l) &&judge(j,i,l,k)&&judge(k,l,i,j)&&judge(l,k,j,i) ) {
num++;
} printf("Case %d: %d\n",cs,num);
}
return ;
}
FZOJ Problem 2148 Moon Game的更多相关文章
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- FZU Problem 2148 Moon Game (判断凸四边形)
题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...
- ACM: FZU 2148 Moon Game - 海伦公式
FZU 2148 Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- FZOJ Problem 2219 StarCraft
...
- 暴力(判凸四边形) FZOJ 2148 Moon Game
题目传送门 题意:给了n个点的坐标,问能有几个凸四边形 分析:数据规模小,直接暴力枚举,每次四个点判断是否会是凹四边形,条件是有一个点在另外三个点的内部,那么问题转换成判断一个点d是否在三角形abc内 ...
- FZU 2148 Moon Game
Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit St ...
- FZU 2148 moon game (计算几何判断凸包)
Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit St ...
- FZOJ Problem 2150 Fire Game
...
- FZOJ Problem 2107 Hua Rong Dao
...
随机推荐
- Luogu [P3367] 模板 并查集
[模板]并查集 题目详见:[[P3367][模板]并查集] (https://www.luogu.org/problemnew/show/P3367) 这是一道裸的并查集题目(要不然叫模板呢) 废话不 ...
- 三倍经验——bzoj3663、4660、4206 Crazy Rabbit/最大团
题目描述: 3663 4660 4206 题解: 第一眼:不成立的互相连边,然后用网络流求解无向图最小点覆盖! 好吧我不会. 正解: 每个点对应圆上的一段圆弧,长这样: 设对应圆弧$(l,r)$. 若 ...
- mysql 添加数据如果数据存在就更新ON DUPLICATE KEY UPDATE和REPLACE INTO
#下面建立game表,设置name值为唯一索引. CREATE TABLE `game` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar( ...
- Python基础——数值
运算 运算 运算符 示例 加 + 减 - 乘 * 除 / 取余 % 幂 ** 赋值 = 绝对值 abs 取整(四舍五入) round 最大值 max 最小值 min 科学计数法 e 十六进制 0x 逻 ...
- Python语言程序设计之二--用turtle库画围棋棋盘和正、余弦函数图形
这篇笔记依然是在做<Python语言程序设计>第5章循环的习题.其中有两类问题需要记录下来. 第一是如何画围棋棋盘.围棋棋盘共有19纵19横.其中,位于(0,0)的星位叫天元,其余8个星位 ...
- Linux集群之高可用负载均衡lvs+keepalived
LVS简介 LVS介绍 LVS是Linux Virtual Server的缩写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统,属于4层负载均衡 ipvs和ipvsadm的关系 我们使用配置LV ...
- MySQL迁移至MariaDB
为什么要用MariaDB来代替MySQL MariaDB是MySQL社区开发的分支,也是一个增强型的替代品.它由MySQL前开发者们带头组织的基金会开发,使用起来和MySQL完全一样.自从Oracle ...
- 实践自己的WebSite______流水
尝试从头至尾搭建一个MVC的网站,主要以流水的方式进行进度和记录,而不讨论技术的部分. 1,在Controller下创建两个文件夹,分别为sys和Business,分别对应于系统功能和业务逻辑.比如登 ...
- SQL_3_表达式、条件语句与运算
加号的两种用法: 1.在SELECT子句中使用+号以执行对数据的运算并将结果显示出来. SELECT ITEM WHOLESALE WHOLESALE+0.15 FROM PRICE; 还可以重命名新 ...
- 使用powershell/vbs自动化模拟鼠标点击操作
今天想做windows上的自动化,所以才有了模拟鼠标点击的需求,先考虑用powershell实现: 首先先安装一个名为“WASP”免费可用的Powershell扩展程序,下载地址:http://was ...