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
...
随机推荐
- C#数组添加元素
一.向数组添加元素 在C#中,只能在动态数组ArrayList类中向数组添加元素.因为动态数组是一个可以改变数组长度和元素个数的数据类型. 示例: using System;using System. ...
- presenting view controller
Present ViewController详解 Present ViewController Modally 一.主要用途 弹出模态ViewController是IOS变成中很有用的一个技术,UIK ...
- 【转】C++后台开发应该读的书
转载自http://www.cnblogs.com/balloonwj/articles/9094905.html 作者 左雪菲 根据我的经验来谈一谈,先介绍一下我的情况,坐标上海,后台开发(也带团队 ...
- 【贪心 计数】bzoj2006: [NOI2010]超级钢琴
这么经典的贪心我怎么现在才做啊…… Description 小Z是一个小有名气的钢琴家,最近C博士送给了小Z一架超级钢琴,小Z希望能够用这架钢琴创作出世界上最美妙的 音乐. 这架超级钢琴可以弹奏出n个 ...
- 洛谷 1571 眼红的Medusa
洛谷 1571 眼红的Medusa 虽说这道题标签里写明了二分,然而我还是首先想到了map......毕竟map真的是简单好写. map做法 #include<bits/stdc++.h> ...
- 理解JWT的使用场景和优劣
理解JWT的使用场景和优劣 淘楼小能手 百家号04-2816:20 经过前面两篇文章<JSON Web Token - 在Web应用间安全地传递信息><八幅漫画理解使用JSON We ...
- centos里没有pip命令怎么办?
刚刚入门python的嘛,然后这个centos也是不是那么熟悉!! pip在centos也没有,所以网上找来资料,3条语句就搞定啦! 1.查看是否安装依赖包,没安装先安装: yum install e ...
- 14Shell脚本—判断语句
判断语句 Shell脚本中的条件测试语法可以判断表达式是否成立,若条件成立则返回数字0,否则便返回其他随机数值. 条件测试语法的执行格式为 [ 条件表达式 ],切记,条件表达式两边均应有一个空格. 条 ...
- 有关git clone 下载速度变慢的解决方法
使用提示:请注意一下,以下方法是在搭有梯子的情况下进行的,也就是说在有梯子的情况下,下载速度始终很慢,使用了以下方法用梯子下载达到正常速度,并没有尝试修复过后不用梯子下载. 所以,如果使用了以下方法, ...
- Django与多个数据库交互
定义数据库 在Django中使用多个数据库的第一步是告诉Django您将要使用的数据库服务器. 数据库可以有您选择的任何别名.但是,别名 default 有着特殊的意义.Django使用别名为 def ...