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的更多相关文章

  1. 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\) ...

  2. Moon.Orm 入门总指南

    注意:下面的pdf文件强烈建议下载或在线查看 1)旗舰版帮助文档点击查看或下载 2)http://pan.baidu.com/s/1hq7krFu(新手手册下载)(强烈推荐) 3)性能及规范下载,网友 ...

  3. Moon.Orm 常见查询实例

    一.Moon.Orm框架总述 (您还用hibernate?实体框架?) 1.框架名:Moon 意思是月亮,而非Mono.因为很喜欢明月,所以以此为名.它是一个.NET下的Orm框架. 2.发展历史:历 ...

  4. Moon.Orm 配置说明

    一.在线技术文档: http://files.cnblogs.com/files/humble/d.pdf   二.使用的大致流程   1.首先下载代码生成器,可以一键生成项目Model层;(其中含有 ...

  5. Codeforces Round #382 Div. 2【数论】

    C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...

  6. Moon.Orm 5.0(MQL版)的高性能,将发言权交给你!

    Moon.Orm 5.0性能问题,我将它交给关心它性能的您,让你自己测试,决不让你失望的. Moon.Orm 5.0 (MQL版) 版本维护及下载 (跟踪发布) Moon.Orm 5.0系列文章 火晋 ...

  7. Moon.Orm 5.0 (MQL版) 欣赏另一种Orm的设计风格----大道至简

    Moon.Orm 5.0(MQL版)使用指南(二) 一.使用sql及存储过程 1)使用List<Dictionary<))) 2)MQL 全面接触

  8. Moon.Orm性能报告

    以下为有网友公司的评估测试及使用规范 大家可以下载word看看 http://pan.baidu.com/s/1hquvRuc 一.和ADO.NET进行的压力测试 说明:2000并发用户,此图为一网友 ...

  9. Moon.Orm与其他Orm的技术对比

    有时候在思考大家为什么喜欢EF,为什么又出现这么多的Orm,为什么Nhiberate被人许多人接收又被许多人拒绝 最后发现结论:萝卜白菜各有所爱.适合自己的就是最好的. EF 微软团队支持(可谓强大的 ...

随机推荐

  1. Java Native Interface 四--JNI中引用类型

    本文是<The Java Native Interface Programmer's Guide and Specification>读书笔记 JNI支持将类实例和数组类型(如jobjec ...

  2. 关于a标签自身的click事件所带来的一些影响

    众所周知a标签自身带有点击事件<a href="#"></a>从它本身的特性来讲并没有什么不好的影响,但是如果你在a标签里又加入onclick事件则< ...

  3. shell 脚本中的运算

    #!/bin/bash read -p "please Insert two integer values: " a b if [ ! -n "$a" -o ! ...

  4. nginx访问量统计

    1.根据访问IP统计UV awk '{print $1}'  access.log|sort | uniq -c |wc -l 2.统计访问URL统计PV awk '{print $7}' acces ...

  5. Linux下安装流量监控工具iftop

    在Linux系统中,top命令可以查看系统资源包括内存,CPU占用信息,查看和探测网络状态可以使用netstat,nmap等工具,实时流量监控可以使用iftop,下面是在CentOS7系列系统上安装i ...

  6. UIPickerView去掉背景上的黑线

    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger) ...

  7. 使用Slf4j集成Log4j2构建项目日志系统的完美解决方案

    一.背景 最近因为公司项目性能需要,我们考虑把以前基于的log4j的日志系统重构成基于Slf4j和log4j2的日志系统,因为,使用slf4j可以很好的保证我们的日志系统具有良好的兼容性,兼容当前常见 ...

  8. List提取相同元素

    List<int> currentList = Cls_Data.SoruceDataIntses[key]; preList = currentList.Intersect(preLis ...

  9. Photoshop 裁剪图片

    如图1选择裁剪工具,然后如图2点一下clear,就可以根据鼠标裁剪任意大小的图片

  10. idea Error:java: Compilation failed: internal java compiler error

    idea 遇到Error:java: Compilation failed: internal java compiler error 是提示说你当前使用的编译器jdk版本不对. 按住Ctrl+Alt ...