FZU-2148-Moon Game,,几何计算~~
Time Limit: 1000 mSec
Memory Limit : 32768 KB
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
题意也不难懂,就是找有多少个凸四边形,而且题目不会有三点共线的情况,开始做的时候想的是用角度判断的方法,,快结束了才知道思路是错的,记得在小白书(算法入门经典)85业看过有向三角形面积计算,目的就是判断一个点是否在三角形内,,这个题就可以用这种思路,也就是说如果所选四个点中有一个点在其他三个点所围成的三角形内部,他就是凹三角形,反之~~~~
有了正确思路,代码就不成问题了吧;
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=50;
struct node
{
int x,y;
} a[N];
int fun(int a)
{
return a>0?a:-a;//因为是有向面积,可正可负;
}
int mj(int x1,int y1,int x2,int y2,int x3,int y3)
{
return fun(x1*y2+x3*y1+x2*y3-x3*y2-x1*y3-x2*y1);//有向面积计算公式;
}
int main()
{
int t,n;
scanf("%d",&t);
int t1=t;
while(t--)
{
int sum=0;
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%d%d",&a[i].x,&a[i].y);
for(int i=1; i<=n-3; i++)
for(int j=i+1; j<=n-2; j++)
for(int k=j+1; k<=n-1; k++)
for(int l=k+1; l<=n; l++)
{
if(mj(a[i].x,a[i].y,a[j].x,a[j].y,a[k].x,a[k].y)==mj(a[i].x,a[i].y,a[j].x,a[j].y,a[l].x,a[l].y)+
mj(a[i].x,a[i].y,a[l].x,a[l].y,a[k].x,a[k].y)+mj(a[l].x,a[l].y,a[j].x,a[j].y,a[k].x,a[k].y))
continue;//点l在中间的情况;
if(mj(a[i].x,a[i].y,a[j].x,a[j].y,a[l].x,a[l].y)==mj(a[i].x,a[i].y,a[k].x,a[k].y,a[l].x,a[l].y)+
mj(a[i].x,a[i].y,a[j].x,a[j].y,a[k].x,a[k].y)+mj(a[l].x,a[l].y,a[j].x,a[j].y,a[k].x,a[k].y))
continue;//点k在中间的情况;
if(mj(a[i].x,a[i].y,a[k].x,a[k].y,a[l].x,a[l].y)==mj(a[i].x,a[i].y,a[j].x,a[j].y,a[l].x,a[l].y)+
mj(a[i].x,a[i].y,a[j].x,a[j].y,a[k].x,a[k].y)+mj(a[l].x,a[l].y,a[j].x,a[j].y,a[k].x,a[k].y))
continue;//点j在中间的情况;
if(mj(a[l].x,a[l].y,a[j].x,a[j].y,a[k].x,a[k].y)==mj(a[i].x,a[i].y,a[j].x,a[j].y,a[l].x,a[l].y)+
mj(a[i].x,a[i].y,a[l].x,a[l].y,a[k].x,a[k].y)+mj(a[i].x,a[i].y,a[j].x,a[j].y,a[k].x,a[k].y))
continue;//点i在中间的情况;
sum++;
}
printf("Case %d: ",t1-t);
printf("%d\n",sum);
}
return 0;
}
FZU-2148-Moon Game,,几何计算~~的更多相关文章
- ACM: FZU 2148 Moon Game - 海伦公式
FZU 2148 Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- 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 ...
- FZU 2148 Moon Game --判凹包
题意:给一些点,问这些点能够构成多少个凸四边形 做法: 1.直接判凸包 2.逆向思维,判凹包,不是凹包就是凸包了 怎样的四边形才是凹四边形呢?凹四边形总有一点在三个顶点的内部,假如顶点为A,B,C,D ...
- FZOJ Problem 2148 Moon Game
Proble ...
- 1549: Navigition Problem (几何计算+模拟 细节较多)
1549: Navigition Problem Submit Page Summary Time Limit: 1 Sec Memory Limit: 256 Mb Su ...
- Jack Straws POJ - 1127 (几何计算)
Jack Straws Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5428 Accepted: 2461 Descr ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- FZU Moon Game(几何)
Accept: 710 Submit: 2038 Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Fa ...
随机推荐
- android开发学习 ------- 枚举类型在Android中的用法
一般上为了简化代码,重用代码,设置标志位来表示不同的流程,这个标志位可以使用枚举类型来表示: 1:定义 public FbManner fbManer = FbManner.EMAIL; //给一个默 ...
- 【C#】将数据库读出的数据转换为DataTable类型集合
return View(ConverDataReaderToDataTable(reader)); // 静态方法public static DataTable ConverDataReaderToD ...
- ImageView控件
ImageView 显示图片 常用属性: src 要显示的图片 foreground 前景图 backgrund 背景图 alpha 透明度 clickable 是否可以点击 onClick ...
- ios 从相册视频中获取视频截图
//给image添加个分类 +(UIImage *)getImage:(NSURL: *)videoURL { AVURLAsset *asset = [[AVURLAsset alloc] init ...
- Oracle 11g r2 Enterprise Manager (EM) 中文页面调整为英文页面
Oracle 11g r2 Enterprise Manager (EM) 在中文语言环境下, 部分功能(如包含时间的查询数据库实例: orcl > 指导中心 > SQL 优化概要 ...
- Centos5安装***
最近shadowsocks挺火,看了几张帖子,感觉在手机上应该挺好用,电脑都是挂着ssh,用不到***了,下面贴出服务器安装过程: yum install build-essential autoco ...
- 字符串循环右移-c语言
一个长度为len的字符串,对其循环右移n位 [期望]char str[] = "abcdefg";右移3次后,变成"efgabcd" [思路] 思路1. 如果用 ...
- 纯手写的css3正方体旋转效果
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- PowerBI 应用时间智能(生成日期表)
简介 Power BI Desktop -是一款由微软发布的自助式商业智能工具,功能强大.易于使用.其中还可以通过微软云连多个数据源并且使用数据源来创建可视化表盘. 但是几乎所有的BI都需要展示如何随 ...
- spring使用elasticsearchrepository时间格式的问题Invalid format: "XXXX-XX-XX" is malformed at "-XX-XX"
Invalid format: "XXXX-XX-XX" is malformed at "-XX-XX" 新手,刚接触elasticsearch遇到的问题. ...