数论 - 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 微软团队支持(可谓强大的 ...
随机推荐
- JS 初级 二(接上)
传送门--http://www.cnblogs.com/Sabo-dudu/p/5786683.html (一) 六. JS 数组类型 数组是一种保存数据的有序列表,数组的每一项可以保存人意类型的数据 ...
- react+redux官方实例TODO从最简单的入门(3)-- 删
上一篇文章我们实现了增删改查中<增>这个功能 那么这一篇我们将实现第二个功能,删! 首先增加一个状态: actions中增加对应的约定 到reducer里面设置执行的函数(这里todo.i ...
- 理解 Delphi 的类(八) - 关于类的定义
//标准语法 TMyClass1 = class(TObject) end; //如果是继承自 TObject 可以省略 TMyClass2 = class end; // ...
- 解决pip安装超时
我们在使用python开发的时候总会需要安装很多第三方模块 比如我用flask搭建web, 需要很多第三方模块,比如flask-sqlalchemy, flask-bootstrap等等.而这些模块用 ...
- 【sdoi2013】森林 BZOJ 3123
Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数.第三行包含N个非负整数 ...
- mapReduce的shuffle过程
http://www.jianshu.com/p/c97ff0ab5f49 总结shuffle 过程: map端的shuffle: (1)map端产生数据,放入内存buffer中: (2)buffer ...
- il c井
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 将resource 替换成 fileComplier 生成的 resx(可以 ...
- 如何在Linux上使用文件作为内存交换区(Swap Area)
交换区域(Swap Area)有什么作用? 交换分区是操作系统在内存不足(或内存较低)时的一种补充.通俗的说,如果说内存是汽油,内存条就相当于油箱,交换区域则相当于备用油箱. Ubuntu Linux ...
- VO对象和PO对象的区别
VO,值对象(Value Object),PO,持久对象(Persisent Object),它们是由一组属性和属性的get和set方法组成.从结构上看,它们并没有什么不同的地方.但从其意义和本质上来 ...
- WEB端实现打印
首先需要下载一个JQ插件: 地址: http://files.cnblogs.com/files/SabWoF/jq%E6%89%93%E5%8D%B0%E6%8F%92%E4%BB%B6%E5%AE ...