数论 - Moon Game
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
2
4
0 0
100 0
0 100
100 100
4
0 0
100 0
0 100
10 10
Sample Output
Case 1: 1
Case 2: 0 -----------------------------------------------------我是分割线^_^-------------------------------------------------------- 题目意思就是说问你在给出的点中最多可以组成多少个凸四边形,此题没做出来,数学底子还是太差了,
直接暴力使用四重循环枚举判断即可,其中对于四边形的判断可以使用面积进行判断,具体图如下:
取四个点,如果有四边形为凹四边形,则必有一个点在其他三个点所形成的三角形内部,所以凸四边形
的问题也是类似的,然后就是求面积了,求面积可以使用向量的叉乘,因为向量a*向量b=|a|*|b|*sin<a,b>,
面积就出来了,于是便进行判断,注意转为浮点数,进行误差处理。
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<queue>
#include<vector>
using namespace std; #define lson rt<<1
#define rson rt<<1|1
#define INF 0x3f3f3f3f
#define Int __int64
typedef pair<int,int> pii; const int MAXN = 55;
pii pos[MAXN]; double Area(pii p1, pii p2, pii p3) {
return fabs(1.0 * (p1.first - p2.first) * (p1.second - p3.second) - (p1.second - p2.second) * (p1.first - p3.first)) / 2.0;
}
bool Ok(pii p1, pii p2, pii p3, pii p4) {
if (fabs(Area(p1, p2, p3) - Area(p1, p2, p4) - Area(p1, p3, p4) - Area(p2, p3, p4)) < 1e-8) return false;
else return true;
}
int main() {
//freopen("input.txt", "r", stdin);
int cas;
while (cin>>cas) {
int sign = 1;
while (cas--) {
printf("Case %d: ", sign++);
int n;
cin>>n;
for (int i = 0; i < n; i++) {
cin>>pos[i].first>>pos[i].second;
}
int ans = 0;
for (int i1 = 0; i1 < n; i1++) {
for (int i2 = i1 + 1; i2 < n; i2++) {
for (int i3 = i2 + 1; i3 < n; i3++) {
for (int i4 = i3 + 1; i4 < n; i4++) {
if (Ok(pos[i1], pos[i2], pos[i3], pos[i4]) &&
Ok(pos[i1], pos[i2], pos[i4], pos[i3]) &&
Ok(pos[i1], pos[i4], pos[i3], pos[i2]) &&
Ok(pos[i4], pos[i2], pos[i3], pos[i1])) {
ans++;
}
}
}
}
}
printf("%d\n", ans);
}
}
return 0;
}
数论 - Moon Game的更多相关文章
- SP19997 MOON2 - Moon Safari (Hard) 【数论,多项式】
题目描述:求 \[ \sum_{i=1}^ni^kr^i \] 对某个质数取模.\(T\)组数据. 数据范围:\(n,r\le 10^{18},\sum k\le 2.56\times 10^6\) ...
- Moon.Orm 入门总指南
注意:下面的pdf文件强烈建议下载或在线查看 1)旗舰版帮助文档点击查看或下载 2)http://pan.baidu.com/s/1hq7krFu(新手手册下载)(强烈推荐) 3)性能及规范下载,网友 ...
- Moon.Orm 常见查询实例
一.Moon.Orm框架总述 (您还用hibernate?实体框架?) 1.框架名:Moon 意思是月亮,而非Mono.因为很喜欢明月,所以以此为名.它是一个.NET下的Orm框架. 2.发展历史:历 ...
- Moon.Orm 配置说明
一.在线技术文档: http://files.cnblogs.com/files/humble/d.pdf 二.使用的大致流程 1.首先下载代码生成器,可以一键生成项目Model层;(其中含有 ...
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- Moon.Orm 5.0(MQL版)的高性能,将发言权交给你!
Moon.Orm 5.0性能问题,我将它交给关心它性能的您,让你自己测试,决不让你失望的. Moon.Orm 5.0 (MQL版) 版本维护及下载 (跟踪发布) Moon.Orm 5.0系列文章 火晋 ...
- Moon.Orm 5.0 (MQL版) 欣赏另一种Orm的设计风格----大道至简
Moon.Orm 5.0(MQL版)使用指南(二) 一.使用sql及存储过程 1)使用List<Dictionary<))) 2)MQL 全面接触
- Moon.Orm性能报告
以下为有网友公司的评估测试及使用规范 大家可以下载word看看 http://pan.baidu.com/s/1hquvRuc 一.和ADO.NET进行的压力测试 说明:2000并发用户,此图为一网友 ...
- Moon.Orm与其他Orm的技术对比
有时候在思考大家为什么喜欢EF,为什么又出现这么多的Orm,为什么Nhiberate被人许多人接收又被许多人拒绝 最后发现结论:萝卜白菜各有所爱.适合自己的就是最好的. EF 微软团队支持(可谓强大的 ...
随机推荐
- 4. K线经典组合及意义一
一. K线的三种形态: 1. 上升形态 2. 下跌形态 3. 顶部及底部形态 二. K线组合三大类 1. 上升形态,当这种K线或K线组合出现,表示股价要上涨. 2. 下跌形态,当这种K线或K线组合出现 ...
- 分页查询和分页缓存查询,List<Map<String, Object>>遍历和Map遍历
分页查询 String sql = "返回所有符合条件记录的待分页SQL语句"; int start = (page - 1) * limit + 1; int end = pag ...
- bzoj4691: Let There Be Light
如果原点能被一个光源照到,那么这两个点之间一定没有任何球.我们可以通过三分距离来确定某线段和球是否有交点. 注意到m非常小,于是我们可以枚举原点被哪些光源照到.由于\(O(2^{n}*m)\)会超时, ...
- Windows下C编程获取软件安装列表信息
代码如下: #include <windows.h> #include <stdio.h> #include <iostream> #include <vec ...
- h5网页的知识点
http://www.tuicool.com/articles/7BfaymE http://blog.csdn.net/minidrupal/article/details/39611605?utm ...
- Linux下的压缩和解压缩命令——zip/unzip
zip命令 zip是个使用广泛的压缩程序,文件经它压缩后会另外产生具有".zip"扩展名 的压缩文件. 选项: -A 调整可执行的自动解压缩文件. -b<工作目录> ...
- html5 拖拽函数1--不兼容火狐
拖拽元素事件<br/>ondragstart拖拽前触发<br/>ondrag拖拽结束之前连续触发<br/>ondragend 拖拽结束前触发<br/>目 ...
- VC++ GetModuleFileName()获取路径字符串中带波浪线~
GetModuleFileName()获取的字符串中带波浪线,不是完整的路径显示. 原因:获取的是短路径,进行了缩写 解决:还原长路径 TCHAR }; GetLongPathName( strTem ...
- mybatis Oracle 批量插入,批量更新
传入的参数只要是list类型的参数就行了..............1.批量插入<insert id="insertBatch" parameterType="ja ...
- Runtime解决屏幕旋转问题
前言 大家或许在iOS程序开发中经常遇到屏幕旋转问题,比如说希望指定的页面进行不同的屏幕旋转,但由于系统提供的方法是导航控制器的全局方法,无法随意的达到这种需求.一般的解决方案是继承UINavrgat ...