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
...
随机推荐
- IEDA的安装与破解
百度搜索IDEA 进入官网下载 https://www.jetbrains.com/idea/download/#section=windows 2.下载好双击即可 3. 完成破解
- ovx openVirtex的阅读文档
由于flowvisor只有4个版本, 最新更新都是2013年的, 跟底层ovs版本不跟进, 最近斯坦福post一个 ovx, 猜测是flowvisor的加强版, 所以看一下文档说明 文档详见http: ...
- Object-C知识点 (五) NSObject的继承关系
这篇文章主要介绍常用的继承自NSObject的类,方便朋友们查看和面试前查看使用!!! 结构图: 更多内容--> 博客导航 每周一篇哟!!! 有任何关于iOS开发的问题!欢迎下方留言!!!或者邮 ...
- (转发)IOS高级开发~Runtime(三)
11.系统类的方法实现部分替换 - (void) methodExchange { Method m1 = class_getInstanceMethod([NSStringclass],@selec ...
- FFT快速傅里叶变化
纪念人生第一次FFT 前排感谢iamzky,讲解非常详细 #include<iostream> #include<cstdio> #include<cmath> u ...
- Linux学习-循环执行的例行性工作排程
循环执行的例行性工作排程则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非常多的例行性工作,因此这个系统服务是默认启动的. 另外, 由于使用者自己也可以进行例行性工 ...
- Python虚拟机之异常控制流(五)
Python中的异常控制语义结构 在Python虚拟机之异常控制流(四)这一章中,我们考察了Python的异常在虚拟机中的级别上是什么东西,抛出异常这个动作在虚拟机的级别上对应的行为,最后,我们还剖析 ...
- jenkins 之 iOS 打包及上传至蒲公英
准备条件 iMAC(要 Mac OS 系统,安卓 和 苹果 可以在同一台电脑上打包) xcode 最新版,要已安装对应的开发证书(生成一个 Ad-Hoc 类型的包就有了) brew(当前管理员账户安装 ...
- windows基本DOS命令
基本命令 dir : 列出当前目录下的文件以及文件夹,后面可以接其他路径 md : 创建目录(mkdir),一次创建多级目录,mkdir a\b\c rd : 删除目录,删除非空目录rd /s(删除最 ...
- Jmeter(四)_逻辑控制器详解
循环控制器: 指定其子节点运行的次数,可以使用具体的数值,也可以设置为变量 1:勾选永远:表示一直循环下去 2:如果同时设置了线程组的循环次数和循环控制器的循环次数,那循环控制器的子节点运行的次数为两 ...